mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-13 23:56:47 +00:00
- Introduced a `SetTimezone` middleware to dynamically apply user-specific timezones. - Added a `timezone chooser` component for users to select their timezone. - Enhanced date and time display in views with `asDate`, `asTime`, and `asDateTime` methods. - Updated `AppServiceProvider` to leverage `preventLazyLoading` in local environments and set custom `Carbon` instance for dates. - Expanded configuration with `user-timezone`. - Integrated timezone support into meetups and events for consistent scheduling.
37 lines
842 B
PHP
37 lines
842 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class SetTimezone
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
if (
|
|
$request->user()
|
|
&& $timezone = $request->user()->timezone
|
|
) {
|
|
config([
|
|
'app.timezone' => $timezone,
|
|
'app.user-timezone' => $timezone,
|
|
]);
|
|
|
|
return $next($request);
|
|
}
|
|
config([
|
|
'app.timezone' => 'Europe/Berlin',
|
|
'app.user-timezone' => 'Europe/Berlin',
|
|
]);
|
|
|
|
return $next($request);
|
|
}
|
|
}
|