Otherwise phpstorm doesn't understand the paths correctly. He thinks that this is not a complete application, but a package. And when creating a class, the namespace indicates “app” with a small letter, but should be “App”.
		
			
				
	
	
		
			20 lines
		
	
	
		
			408 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			408 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php declare(strict_types=1);
 | 
						|
 | 
						|
namespace App\Http\Middleware;
 | 
						|
 | 
						|
use Closure;
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Illuminate\Support\Facades\App;
 | 
						|
 | 
						|
final class UserLocale
 | 
						|
{
 | 
						|
    public function handle(Request $request, Closure $next)
 | 
						|
    {
 | 
						|
        if ($request->user() && $request->user()->lang) {
 | 
						|
            App::setLocale($request->user()->lang->getLocale());
 | 
						|
        }
 | 
						|
 | 
						|
        return $next($request);
 | 
						|
    }
 | 
						|
}
 |