Laravel get logged in user data

2020-07-12 15:06:46 Priyag Laravel

In this trick we are going to see how to get logged in user data in laravel. You can get logged in user data using Auth facade in laravel.

Below is simple Auth facade example

$userInfo=\Auth::user();
dd($userInfo);


Getting specific key like name, email from Auth Facade

$userInfo=\Auth::user();
$userInfo->name;  // return name of loggedin user
$userInfo->email;  // returns loggedin user email

This post is submitted by one of our members. You may submit a new post here.

Related Tricks