Today's leading topic is laravel 5.8 get current user details using auth. i will show you how to get current logged in user id, name, email, created_at, role etc using auth() helper or Auth facade class.
we can easily get auth user data using auth helper in laravel 5.8 application.
we almost need to get current logged in user data because we need to some restrict to pages or get only login user data so at that time we must need to get logged in user details like id or name.
So, we can get current user details using laravel auth. You can also use simple auth helper or Auth facade. So i will give you both example, you can take any one as you want. So let's see both examples one by one.
$user = auth()->user();
$user = Auth::user();
I hope you found your best solution...
Do you like below Tutorials ?
- Laravel 5.5 validation example with custom message
- Laravel 5.5 create zip archive file and download example
- Laravel 5.5 Jquery Ajax Request Example From Scratch
- Laravel 5.5 pagination example from scratch
- Ajax CRUD example in Laravel 5.5 application
- Class Form not found in Laravel 5.5
- Laravel 7.x and 6.x get last query log example
- Laravel 5.5 Image Upload example