user(); if (! $user) { abort(403); } // Handle profile update if ($request->isMethod('post')) { $action = $request->input('confirm'); if ($action === 'true_password') { $old = $request->input('oldpass'); $new = $request->input('newpass'); $new2 = $request->input('newpass2'); if ($new && $new === $new2 && Hash::check($old, $user->password)) { $user->password = Hash::make($new); $user->save(); $request->session()->flash('status', 'Password changed.'); } else { $request->session()->flash('error', 'Password not changed.'); } } else { $data = $request->only(['real_name','web','country_code','signature','description','about_me']); $user->real_name = $data['real_name'] ?? $user->real_name; $user->web = $data['web'] ?? $user->web; $user->country_code = $data['country_code'] ?? $user->country_code; $user->signature = $data['signature'] ?? $user->signature; $user->description = $data['description'] ?? $user->description; $user->about_me = $data['about_me'] ?? $user->about_me; $d1 = $request->input('date1'); $d2 = $request->input('date2'); $d3 = $request->input('date3'); if ($d1 && $d2 && $d3) { $user->birth = sprintf('%04d-%02d-%02d', (int)$d3, (int)$d2, (int)$d1); } $user->gender = $request->input('gender', $user->gender); $user->mlist = $request->has('newsletter') ? 1 : 0; $user->friend_upload_notice = $request->has('friend_upload_notice') ? 1 : 0; if ($request->hasFile('avatar')) { $f = $request->file('avatar'); $name = $user->id . '.' . $f->getClientOriginalExtension(); $f->move(public_path('avatar'), $name); $user->icon = $name; } if ($request->hasFile('personal_picture')) { $f = $request->file('personal_picture'); $name = $user->id . '.' . $f->getClientOriginalExtension(); $f->move(public_path('user-picture'), $name); $user->picture = $name; } if ($request->hasFile('emotion_icon')) { $f = $request->file('emotion_icon'); $name = $user->id . '.' . $f->getClientOriginalExtension(); $f->move(public_path('emotion'), $name); $user->eicon = $name; } $user->save(); $request->session()->flash('status', 'Profile updated.'); } } // Prepare birth date parts for the legacy form $birthDay = null; $birthMonth = null; $birthYear = null; if (! empty($user->birth)) { try { $dt = Carbon::parse($user->birth); $birthDay = $dt->format('d'); $birthMonth = $dt->format('m'); $birthYear = $dt->format('Y'); } catch (\Throwable $e) { // ignore parse errors } } // Load country list if available (legacy table names) $countries = collect(); try { if (Schema::hasTable('country_list')) { $countries = DB::table('country_list')->orderBy('country_name')->get(); } elseif (Schema::hasTable('countries')) { $countries = DB::table('countries')->orderBy('name')->get(); } } catch (\Throwable $e) { $countries = collect(); } return view('legacy.user', [ 'user' => $user, 'birthDay' => $birthDay, 'birthMonth' => $birthMonth, 'birthYear' => $birthYear, 'countries' => $countries, ]); } }