Here, i will let you know how to get current logged in user in laravel 5.7 app. you can get current user id in controller, view files. we will user auth() helper and Auth facade class to get current user data.
we always require getting current logged in user data in laravel 5.7 application. I will show you how to get current user data like name, id, email, address etc by using laravel 5.7 auth. I will give you two way to get current user data using laravel authentication. you can simply get logged in user details in controller or view blade files. As you would like to get it.
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 ?
- Angular 9 HttpClient Request with RxJS Observable Example
- How to Create Routing Module in Angular 9?
- How to Create Custom Directive in Angular 9?
- Print Iframe Content using JQuery Example
- Allow Only Numeric Values in Textbox using JQuery
- Codeigniter Confirmation Box Before Delete Item Example
- How to Use Sweet Alert in Codeigniter?