Created
November 23, 2021 16:11
-
-
Save chasecmiller/137bb7e194f3e780b94cd7eed043af12 to your computer and use it in GitHub Desktop.
Share user to all views in Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is a dead simple way to share your current user within all views in a traditional website. | |
* Make sure you are importing Illuminate\Support\Facades\View into your AppServiceProvider, | |
* then add this to the boot method. Once you do that, you can use the $user variable at | |
* any point in the view to get your currently authenticated view. | |
*/ | |
View::share('user', \Auth::user()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment