Answer the question
In order to leave comments, you need to log in
Why doesn't Auth work in laravel?
Good day to all.
The problem is this, I updated Laravel to 5.3 and part of the code does not work
use Illuminate\Support\Facades\Auth;
public function __construct()
{
$this->user = Auth::user();
view()->share('user', $this->user);
}
Answer the question
In order to leave comments, you need to log in
Are you using this in the controller's constructor?
https://laravel.com/docs/5.3/upgrade
Session In The Constructor
In previous versions of Laravel, you could access session variables or the authenticated user in your controller's constructor. This was never intended to be an explicit feature of the framework. In Laravel 5.3, you can't access the session or authenticated user in your controller's constructor because the middleware has not run yet.
As an alternative, you may define a Closure based middleware directly in your controller's constructor. Before using this feature, make sure that your application is running Laravel 5.3.4 or above:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question