On laravel 9 site I fill some init data in seeders and I use line :
Auth::loginUsingId($defaultAdminId);
and in model_has_permissions table I have a row referenced $defaultAdminId and Admin permission in permissions table
But later checking is logged is admin
if ( Auth::user()->can(ACCESS_ADMIN) ) { // Is Admin
...
The checks above does not work . I suppose method Auth::loginUsingId( does not know anything about model_has_permissions table . If there is a way to set spatie/permission access after calling Auth::loginUsingId( ?
"laravel/framework": "^9.26.1",
"spatie/laravel-permission": "^5.5.5"
"laravel/passport": "^10.4.1",
Thanks in advance!
I found a decision with code :
Auth::user()->load('permissions');
on login.