jeudi 28 septembre 2017

trying to get property of non-object on laravel 5.4 constructor Auth::user()->id

I use Laravel 5.4.36. When I use Auth::user()->id on constructor method show me this error

(1/1) ErrorException
Trying to get property of non-object
in UserController.php (line 25)

My controller:

public function __construct()
{
    echo Auth::user()->id;

}  

But when I use Auth::user()->id on index method show me 2

    public function __construct()
{
    echo Auth::user()->id;

} 

result is : 2



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xDk9m1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire