Laravel 7/6 Get Current User Example

Laravel 7/6 Get Current User Example

In this post we will give you information about Laravel 7/6 Get Current User Example. Hear we will give you detail about Laravel 7/6 Get Current User ExampleAnd how to use it also give you demo for it if it is necessary.

Today, i want to add small tutorial for how to get current user data in laravel 7/6 application. i will show you how to get current user id, current user name, current user email address in laravel 7/6 app. you can easily get current login user id in controller of laravel 7/6. we will get current user data using auth in laravel 7/6.

It’s most important thing is when you are working with authentication then you know how to get my current login user details. so i will give you example how you can get current user data in laravel 7/6. laravel 7/6 provide auth for authentication, using auth you can easily get current login user data with email, name and id.

So, let’s see i added two way to getting current user data in laravel 6 application.

Auth Helper:

Here, we will get current user data using auth() in laravel 6.

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

var_dump($user->id);

var_dump($user->name);

var_dump($user->email);

Output:

12

Hardik

onlinecode@gmail.com

Auth Facade:

Here, we will get current user data using Auth Facade in laravel 6.

$user = Auth::user();

var_dump($user->id);

var_dump($user->name);

var_dump($user->email);

Output:

Also see:Laravel 6 Install Vue JS Example

12

Hardik

onlinecode@gmail.com

I hope it can help you…

Hope this code and post will helped you for implement Laravel 7/6 Get Current User Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

35  +    =  36

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US