From d0742edc1ddfe81f9ae5910faa19dd669f5f640f Mon Sep 17 00:00:00 2001 From: Juan Manuel Corigliano Giuliani <126042007+juancorax@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:34:19 -0300 Subject: [PATCH] Complete tasks --- .../Auth/RegisteredUserController.php | 3 +- app/Http/Controllers/ProfileController.php | 10 ++ app/Models/User.php | 2 +- resources/views/auth/profile.blade.php | 37 ++--- resources/views/layouts/navigation.blade.php | 129 +++++++++--------- routes/web.php | 10 +- 6 files changed, 95 insertions(+), 96 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index d8d29eb5..45b1bad4 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -26,7 +26,6 @@ public function create() /** * Handle an incoming registration request. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException @@ -37,7 +36,7 @@ public function store(Request $request) $request->validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], - 'password' => ['required', 'confirmed', Rules\Password::defaults()], + 'password' => ['required', 'confirmed', Rules\Password::letters()], ]); $user = User::create([ diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index e0093a49..99f8dc40 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -14,7 +14,17 @@ public function show() public function update(ProfileUpdateRequest $request) { // Task: fill in the code here to update name and email + $user = $request->user(); + + $user->name = $request->input('name'); + $user->email = $request->input('email'); + // Also, update the password if it is set + if ($user->password) { + $user->password = $request->input('password'); + } + + $user->save(); return redirect()->route('profile.show')->with('success', 'Profile updated.'); } diff --git a/app/Models/User.php b/app/Models/User.php index e23e0905..12a2354b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -8,7 +8,7 @@ use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; -class User extends Authenticatable +class User extends Authenticatable implements MustVerifyEmail { use HasApiTokens, HasFactory, Notifiable; diff --git a/resources/views/auth/profile.blade.php b/resources/views/auth/profile.blade.php index 70e8a8e1..cbb3cd50 100644 --- a/resources/views/auth/profile.blade.php +++ b/resources/views/auth/profile.blade.php @@ -10,7 +10,7 @@
- + @@ -22,44 +22,31 @@ Task: replace ??? for name/email with logged in user's name/email

- + {{-- Task: replace ??? for name/email with logged in user's name/email --}} - +
- + - +
- + - +
- + - +
diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php index 785936e7..99014ca4 100644 --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -6,7 +6,7 @@ @@ -16,49 +16,53 @@ {{ __('Users') }} {{-- Task: this "Profile" link should be visible only to logged-in users --}} - - {{ __('Profile') }} - + @auth + + {{ __('Profile') }} + + @endauth
@@ -66,13 +70,13 @@ class="flex items-center text-sm font-medium text-gray-500 transition duration-1
@@ -80,38 +84,39 @@ class="inline-flex justify-center items-center p-2 text-gray-400 rounded-md tran -