Ekapp/skolehjem/app/Http/Middleware/SetLocale.php

27 lines
532 B
PHP
Raw Normal View History

2020-08-07 06:52:01 +00:00
<?php
namespace App\Http\Middleware;
use Closure;
2020-08-11 07:13:48 +00:00
use Illuminate\Http\Response;
2020-08-07 06:52:01 +00:00
class SetLocale
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
2020-08-11 07:13:48 +00:00
if($request->user() != null)
app()->setLocale($request->user()->getLocale($request));
else
return redirect()->route("users.login");
2020-08-07 06:52:01 +00:00
return $next($request);
}
}