diff --git a/app/Actions/User/UpdateUserProfileInformation.php b/app/Actions/User/UpdateUserProfileInformation.php index 6efa12c1..422f97ef 100755 --- a/app/Actions/User/UpdateUserProfileInformation.php +++ b/app/Actions/User/UpdateUserProfileInformation.php @@ -19,6 +19,10 @@ public function update(User $user, array $input): void Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], + 'timezone' => [ + 'required', + Rule::in(timezone_identifiers_list()), + ], ])->validateWithBag('updateProfileInformation'); if ($input['email'] !== $user->email) { @@ -27,6 +31,7 @@ public function update(User $user, array $input): void $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], + 'timezone' => $input['timezone'], ])->save(); } } @@ -39,6 +44,7 @@ protected function updateVerifiedUser(User $user, array $input): void $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], + 'timezone' => $input['timezone'], ])->save(); } } diff --git a/app/Http/Livewire/Profile/UpdateProfileInformation.php b/app/Http/Livewire/Profile/UpdateProfileInformation.php index 95802864..6d87f1c9 100644 --- a/app/Http/Livewire/Profile/UpdateProfileInformation.php +++ b/app/Http/Livewire/Profile/UpdateProfileInformation.php @@ -15,10 +15,13 @@ class UpdateProfileInformation extends Component public string $email; + public string $timezone; + public function mount(): void { $this->name = auth()->user()->name; $this->email = auth()->user()->email; + $this->timezone = auth()->user()->timezone; } /** diff --git a/resources/views/livewire/profile/update-profile-information.blade.php b/resources/views/livewire/profile/update-profile-information.blade.php index fd2e4f2b..fcbf0bad 100644 --- a/resources/views/livewire/profile/update-profile-information.blade.php +++ b/resources/views/livewire/profile/update-profile-information.blade.php @@ -45,6 +45,18 @@ @endif + +
+ + + @foreach(timezone_identifiers_list() as $timezone) + + @endforeach + + @error('timezone') + + @enderror +
diff --git a/tests/Feature/Http/ProfileTest.php b/tests/Feature/Http/ProfileTest.php index 70ef2d9c..88ac72fc 100644 --- a/tests/Feature/Http/ProfileTest.php +++ b/tests/Feature/Http/ProfileTest.php @@ -29,6 +29,7 @@ public function test_profile_information_can_be_updated(): void Livewire::test(UpdateProfileInformation::class) ->set('name', 'Test') ->set('email', 'test@example.com') + ->set('timezone', 'Europe/Berlin') ->call('submit') ->assertSuccessful(); @@ -36,5 +37,6 @@ public function test_profile_information_can_be_updated(): void $this->assertSame('Test', $this->user->name); $this->assertSame('test@example.com', $this->user->email); + $this->assertSame('Europe/Berlin', $this->user->timezone); } }