Problem with permission and routes. #2031
-
Hi, I don't figure out what i'm doing wrong. I have a Controller, on the constructor create all: Permissions and Roles
The two roles Aeropuerto and AeropuertoAlta define who can access the table aeropuertos and who can also modify or eliminate the data within. The problem is in route/web.php:
When the user has the Role AeropuertoAlta can access all the routes except the route aeropuertos/create |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Beta Was this translation helpful? Give feedback.
-
First i don't understand why that code is on Controller constructor, that must be on sedder or migration , also you always are cleaning cache, that makes cache useless, maybe middleware on route executes before than the controller, hard to say because I wouldn't use the code like that in any situation. You can use |
Beta Was this translation helpful? Give feedback.
-
To keep this solution if anybody find useful in the future: App/Http/Controllers/AuditoriasController.php
routes/web.php
app/helpers.php
|
Beta Was this translation helpful? Give feedback.
First i don't understand why that code is on Controller constructor, that must be on sedder or migration , also you always are cleaning cache, that makes cache useless, maybe middleware on route executes before than the controller, hard to say because I wouldn't use the code like that in any situation.
You can use
syncPermissions
for avoid so many if/else, also there isfirstOrCreate
method