Sure just add it here https://github.com/laravel/laravel/blob/9.x/app/Http/Kernel.php#L38
Sep 21, 2022
9
Level 8
Using permission-checking middleware once instead of many times
I deleted my previous post as I posted it with mistakes. This is the current situation: There are two tables:
- List of permission groups:
id | permission_group
---|------------------
1 | permission_group_x
2 | permission_group_y
3 | permission_group_z
- List of users with their assigned groups:
user_id | permission_group_id
--------|---------------------
97 | 1
11 | 2
11 | 3
53 | 3
81 | 3
53 | 1
Then in web.php, each route group is assigned a Middleware that gets a list of all allowed permission groups, and if the current user is in any of these groups (a user can be in more than one group), then he has access. Otherwise you redirect the user to a forbidden page.
But right now because there are hundreds of routes, I am using this Middleware hundreds of times.
Is there any way to convert it to wrap all the routes?
Please or to participate in this conversation.