I know how to assign permissions to user.
class User extends Authenticatable
{
use HasRoles;
}
$user->givePermissionTo('edit articles');
In this case, in model_has_permissions table will be inserted like this.
permission_id=> $permission_id
model_type=> "App\Models\User"
model_id=> $user_id
I have Team Model and I want to give permission to Team too. This is what I did.
class Teamextends Authenticatable
{
use HasRoles;
}
$team->givePermissionTo('edit articles');
I wanted this result,
permission_id=> $permission_id
model_type=> "App\Models\Team"
model_id=> $team_id
But it didn't work for me. Anyone has experience such as above things? Should I make another table for it? like team_has_permission
?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire