Aknaproff/app/Http/Middleware/SetDefaultConfigForUser.php

32 lines
673 B
PHP
Raw Normal View History

2023-09-21 12:45:08 +00:00
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class SetDefaultConfigForUser
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = Auth::user();
if (! empty($user->settings['timezone'])) {
config(['app.timezone' => $user->settings['timezone']]);
}
if (! empty($user->settings['language'])) {
config(['app.locale' => $user->settings['language']]);
}
return $next($request);
}
}