i'm using custom guard
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'user' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
i want to get admin name on blade so i call it using
{{ Auth::guard('admin')->name }}
but i got error
Cannot access protected property Illuminate\Auth\SessionGuard::$name
how can i achieve this on laravel 5.3
Are you trying to get the name of the SessionGuard object or the name of the user that is signed in using the
adminguard?This might be what you are looking for:
Just note that the above will only work if the user is logged in, as the
usermethod will returnnullwhen they're not logged in. Here's how you'd check if they are logged in: