File tree Expand file tree Collapse file tree 4 files changed +13
-0
lines changed Expand file tree Collapse file tree 4 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ APP_ENV=local
33APP_KEY = base64:jpd/wy450S/8N0y6OfuRoZ8yS3AWEzrbkSgo08djF4w=
44APP_DEBUG = true
55APP_URL = http://laravel-inertia-template.test
6+ APP_TIMEZONE_DISPLAY = " Europe/London"
67
78SEED_SUPER_ADMIN_EMAIL = super@laravel-inertia-template.test
89SEED_ADMIN_EMAIL = admin@laravel-inertia-template.test
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ APP_ENV=testing
33APP_KEY = base64:PGFsMHQa3kYad6OZbsaYzBnrdzxN3x+sfkkmqogVDuk=
44APP_DEBUG = true
55APP_URL = http://laravel-inertia-template.test
6+ APP_TIMEZONE_DISPLAY = " Europe/London"
67
78BCRYPT_ROUNDS = 4
89
Original file line number Diff line number Diff line change 33namespace App \Providers ;
44
55use App \Models \User ;
6+ use Carbon \Carbon ;
67use Illuminate \Http \Resources \Json \JsonResource ;
78use Illuminate \Support \ServiceProvider ;
89use Laravel \Pulse \Facades \Pulse ;
@@ -24,6 +25,14 @@ public function boot(): void
2425 {
2526 JsonResource::withoutWrapping ();
2627
28+ Carbon::macro ('inAppTimezone ' , function () {
29+ return $ this ->tz (config ('app.timezone_display ' ));
30+ });
31+
32+ Carbon::macro ('inUserTimezone ' , function () {
33+ return $ this ->tz (auth ()->user ()?->timezone ?? config ('app.timezone_display ' ));
34+ });
35+
2736 // @codeCoverageIgnoreStart
2837 Pulse::users (function ($ ids ) {
2938 return User::findMany ($ ids )->map (fn ($ user ) => [
Original file line number Diff line number Diff line change 6767
6868 'timezone ' => env ('APP_TIMEZONE ' , 'UTC ' ),
6969
70+ 'timezone_display ' => env ('APP_TIMEZONE_DISPLAY ' , 'UTC ' ),
71+
7072 /*
7173 |--------------------------------------------------------------------------
7274 | Application Locale Configuration
You can’t perform that action at this time.
0 commit comments