Answer the question
In order to leave comments, you need to log in
Where to structure access control in Laravel?
Hello. There is a category model and notes in Laravel. Roles are attached to standard authorization (each role has a numerical value of its weight, for example, user 100, editor 1000, administrator 9999). Where to architecturally attribute the tolerance check upon receipt of the next request. The permission can be either explicit (the request is allowed / denied in principle, for example, the user cannot create a category, unlike the admin), or limited (for example, the editor cannot explicitly delete the category if it contains an article or subcategory, but the admin can). What is the best way to implement this?
I was thinking of splitting the check into 2 parts. The first through middlware (as in the documentation) checks the weight of the user's role for a specific operation (i.e. Auth::user()->role->weight >= 1000 is the editor's permission and higher), and specific checks like deletion restrictions are carried out directly in the controller.
Thank you in advance
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question