movepixels said:
Is it possible to prefix the methods in a controller to easily distinguish between role access?
Example AnyThingController might have index(){} which is considered public for anyone where as admin_index(){} would be for the index when logged in as user.
The site I am working on is all role / permission based and its just a preference to clearly see that prefix before to easily identify from other functions.
Thanks all.
Dave
I'm not at all certain about this, but I have a theory of what could work... In the controller's constructor, you can always place your middlewares if you like, and you can decide to only apply them on certain routes. I assume you could have some regex to apply it to all routes starting with admin.
However, I would create a separate admin controller, both for the sake of separating purpose, and for readability and ease of implementation
Cheers, Leo
I have nothing set in place for any routing / controller or anything coded. I am coming from another framework and the ability to prefix the route with prefix => whatever and in the controller whatever_action(){.....} would produce a url www.site/whatever/action so if you were trying to access anything with prefix "whatever" and you had permission to access "whatever" routes it made permissions much easier, mangers were prefixed with manage, editors with editors, admin with admin , you get the picture, each had different permissions for the site. i dont want to make 3 sets of controllers for ManagerProfile, EditorProfile, AdminProfile that makes no sense. A single Profile controller with mange_profile(){.....} admin_profile{.....} editor_profile{......}
To me that is much easier. The site is Role permission based, not per user, rather by role so all Managers have same permissions and so on with Editors, Admins
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community