I need to share the currently logged in user to all views. I am attempting to use the view->share() method within AppServiceProvider.php file.

I have the following:

<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Contracts\Auth\Guard; class AppServiceProvider extends ServiceProvider { public function boot(Guard $guard) { view()->share('guard', $guard); view()->share('user', $guard->user()); } //.. }

However, when I hit up a view (after logging in), the user variable is null. Strangely, the $guard->user (the protected attribute, not the public method user()) is not. The output I get is the following:

Note the guard->user variable is populated, but the user variable is null.