Jul 18, 2021
0
Level 7
with or withCount with users relation shows an error laravel spatie permissions.
with or withCount works with permissions relation but when you add users relation it shows an error.
And also when you do it on tinker it goes completely fine. Very strange
My code
$roles = QueryBuilder::for(Role::class)
->allowedSorts('name')
->withCount('users')
->withCount('permissions')
->where('name', '!=', 'owner')
->where('guard_name', 'web')
->where('user_id', $user->id)
->get(['name', 'id']);
return inertia('roles/staff/Index', ['roles' => $roles]);
Error
Class name must be a valid object or a string
Please or to participate in this conversation.