Skip to content

Commit f1ab177

Browse files
authored
Add clarity about coding for permissions
1 parent 9adc4b2 commit f1ab177

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/best-practices/roles-vs-permissions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: Roles vs Permissions
33
weight: 1
44
---
55

6-
It is generally best to code your app around `permissions` only. That way you can always use the native Laravel `@can` and `can()` directives everywhere in your app.
6+
It is generally best to code your app around testing against `permissions` only. (ie: when testing whether to grant access to something, in most cases it's wisest to check against a `permission`, not a `role`). That way you can always use the native Laravel `@can` and `can()` directives everywhere in your app.
77

8-
Roles can still be used to group permissions for easy assignment, and you can still use the role-based helper methods if truly necessary. But most app-related logic can usually be best controlled using the `can` methods, which allows Laravel's Gate layer to do all the heavy lifting.
8+
Roles can still be used to group permissions for easy assignment to a user/model, and you can still use the role-based helper methods if truly necessary. But most app-related logic can usually be best controlled using the `can` methods, which allows Laravel's Gate layer to do all the heavy lifting. Sometimes certain groups of `route` rules may make best sense to group them around a `role`, but still, whenever possible, there is less overhead used if you can check against a specific `permission` instead.
99

1010
eg: `users` have `roles`, and `roles` have `permissions`, and your app always checks for `permissions`, not `roles`.
1111

0 commit comments

Comments
 (0)