Replies: 1 comment
-
You can overwrite migration and trait methods, and do everything you need. public function hasPermissionTo($permission, $guardName = null): bool
{
$permissionClass = $this->getPermissionClass();
if (is_string($permission)) {
$permission = $permissionClass->findByName($permission, $this->getDefaultGuardName());
}
if (is_int($permission)) {
$permission = $permissionClass->findById($permission, $this->getDefaultGuardName());
}
if ($permission instanceof Permission && $assigned = $this->permissions->where('id', $permission->id)) {
$options = $assigned->pivot->options;
if (/* $options don't pass validations */) {
return false;
}
}
return $this->hasPermissionToFromParent($permission, $guardName);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to know, if you have considered adding an additional field to the pivot table, for example model-permission.
I have users to which certain days I need to disable access, control the amount of daily and monthly posts, comments, updates, etc. that they can do, I would like to be able to control this metadata from the same permission when assigning it to a user.
Example:
Something like this would help me to better control this metadata, I currently have additional tables for it, but it seems not very flexible, since I can reuse the pivot tables that spatie already has for the same.
This can be extended for roles and teams.
Beta Was this translation helpful? Give feedback.
All reactions