How to Get Current Login User Details in Laravel 8 Example ?

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
How to Get Current Login User Details

Hello Dev’s
Now today in this tutorial will show you laravel 8 get login user details by using auth. Here i will show you how to get current login user details in laravel 8 application. From here we get name, email, created_at, role etc by using auth() helper or also Auth facade class.

So now from here we can easily get auth user information by using auth helper in our laravel 8 application.

So we almost need to get current log in user data in our application because of we need to make some restrict to pages or get only login user data so at that time. For this our must need data of a log in user details as like as id or name.

So, now we can get current user details by using laravel 8 auth. we can also get by use simple auth helper or also Auth facade. So now i will give you both examples, now we can take any one as we want. So let’s start and see both examples one by one.

Using Helper:

$user = auth()->user();

print($user->id);

print($user->name);

print($user->email);

Using Facade:

$user = auth()->user();

print($user->id);

print($user->name);

print($user->email);

Read Also : Laravel 6 CRUD Operation

Thanks for read. I hope it help you. For more you can follow us on facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →