Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel middleware in constructor

public function __construct(User $user)
{
  	$this->user = $user;
  
    $this->middleware(function ($request, $next) {
        $user = auth()->user();
        if ($user) {
          	$this->user = $user;
        }
      
        return $next($request);
    });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #middleware #constructor
ADD COMMENT
Topic
Name
6+4 =