mercredi 26 août 2015

Laravel making a global object with AppServiceProvider

When I'm trying to make a user object in App\Providers\AppServiceProvider like this:

    public function boot()
{
    $user = Auth::user();
    view()->share('user',$user);
}

And when I'm saying in for example index.blade.php:

{!! $user->name !!}

It throws the error:

Trying to get property of non-object (View: D:\wamp\www\resources\views\tickets\index.blade.php)

So obviously the object is empty but why is that? Ofcourse when I tested this I was logged in.



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

Aucun commentaire:

Enregistrer un commentaire