How to check auth guard in Laravel ? | Laravel Check Login Guard
Jun 18, 2020
Hi Guys,
In this example,I will learn you how to check auth guard in larravel.you can easy and simply ckeck login guard in laravel.
The Auth Guards are a vastly unexplored part of most Laravel applications, since the ones that come by default already do a great job to log in users.
Check Blade :
@if(Auth::guard('admin')->check())
Hi {{Auth::guard('admin')->user()->name}}
@elseif(Auth::guard('user')->check())
Hi {{Auth::guard('user')->user()->name}}
@endif
Check Controller :
if(Auth::guard('admin')->check()){
dd(Auth::guard('admin')->user()->name);
}
elseif(Auth::guard('user')->check()){
dd(Auth::guard('user')->user()->name);
}
Get Controller :
public function index(){
$userName = Auth::guard('admin')->user()->name;
dd($userName);
}
Get Blade :
Hi {{Auth::guard('admin')->user()->name}}
It will help you..
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial