Search code examples
laravelubuntularavel-5laravel-spark

Getting the Current User


I am sorry for the dumb question, but I am new at this programming thing and having fun. How do I get the current user in a base Laravel Spark project? I know what the Laravel Spark documentation says, but I can't seem to get the information even with that. I guess I just need an example. Any help would be appreciated. :)


Solution

  • you can access the current authorized user by using the Auth facade. $user = Auth::user(); Make sure to add use Auth; at the top of your file!

    Adding on top of this, if you just need something small like the logged-in users's ID, you can say Auth::id()