jamesmills / laravel-timezone

Enable user Timezones in your application.
MIT License
675 stars 89 forks source link

Add timezone select to Jetstream profile page? #73

Open seabasss opened 3 years ago

seabasss commented 3 years ago

Is there any way to add a timezone select to the Jetstream profile page? I only want to set timezone automatically when the user first log in and then let them change it under profile settings.

Has anyone built a select like that? I tried to add one, but quickly added up deep in laravel/jetstream core folders and figured I better ask here first.

Thanks!

sirmews commented 3 years ago

@seabasss I've done this by:

First edit the component for user profile: resources/views/profile/update-profile-information-form.blade.php

Add a select here with a list of timezones. You can get a timezone list using listidentifiers

Then allow the timezone input in app/Actions/Fortify/UpdateUserProfileInformation.php. You'll notice this is where the User model is updated, pass in the appropriate timezone value.

You'll want to add timezone to your user Model's $fillable if you resort to using the default $user->forceFill

Hope this helps.