-
-
Notifications
You must be signed in to change notification settings - Fork 466
Closed
Description
I have encountered problem where I have users with multiple roles and I want role1 to be able to manage users with role2 that belong to same model through belongsTo() relation.
I have written policy:
public function view(User $user, User $model)
{
return true;
if ($user->location->id === $model->location->id && $model->hasRole('role1')) {
return true;
}
return false;
}when I use @can directive, policy works, but does not hit resolver due model: definition.
If I remove model from query, resolver is triggered, but policy fails due not passing 2nd argument, I get there only signed in user data.
last I tried to use $this->authorize('view', $user); within resolver, which throws error that authorize is undefined method.
Metadata
Metadata
Assignees
Labels
No labels