79240654

Date: 2024-11-30 23:26:40
Score: 1.5
Natty:
Report link

According to the documentation from spatie, it is best practice to assign permission to users through roles. I.e first creating roles, then assigning permissions to these roles. Which are in turn assigned to the user by calling the assignRole method on the user model. Please see example here. But in the eventuality that you'd rather give direct permission to the user, you need to have given permission to the user using the givePermissionTo method directly on the user object. This I suppose would occur at the point of creating a new user, editing an existing user account or triggering a user event. After which you can then call the code you have written to return users and their permissions. Please see reference to an example on spatie's website on using direct permissions.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Olumuyiwa