Answer the question
In order to leave comments, you need to log in
How to define authenticated user in Laravel controller constructor?
Found in the documentation that since version 5.3 you can't use the Auth facade to get the authenticated user in the controller's constructor, but only with a Closure-based proxy. But how to do it? Show me with an example. The code below gives an error that the $user object does not exist:
public function __construct(){
$this->user=auth()->user();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question