I am Try to get User List with their role in laravel 8, for role and permission i am use spatie package (https://spatie.be/docs/laravel-permission/v4/)
i am trying to get any data via user it return error
following function return error
$all_users_with_all_their_roles = User::with('roles')->get();
$all_users_with_all_direct_permissions = User::with('permissions')->get();
$user->hasAllRoles(Role::all());
function (https://spatie.be/docs/laravel-permission/v3/basic-usage/basic-usage#eloquent)
ERROR : "Call to undefined method App\Models\User::getAllPermissions()",…}
I think something missing in user model.
please help to solve this issue
TIA
I think you forgot to add the trait to the User class:
If you have not forgotten the trait, then use the below code to get all users
roles
andpermissions
.FMI SEE: https://spatie.be/docs/laravel-permission/v3/basic-usage/basic-usage