I have lot of modules, each module have one controller, each controller have create,view,delete, edit methods.now assign permissions to roles.each permission have 4 sub permissions. how to control methods in a controller.
Asked
Active
Viewed 790 times
1 Answers
0
To avoid repeating yourself and to write 'DRY'(Don't Repeat Yourself) code, there're a few ways to do.
Middleware Middleware is a piece of functionality which can be used within a whole controller, under a route-group, and more. For more information, I'd recommend you to read here :
Policies
Next to middelware Laravel has a functionality called Policies. Which will be defined on model-level. For more information I'd redirect you to :
Laravel Docs Authorization/Policies
Hope this helped you, excuse me for my English skills..

JoeriShoeby
- 1,374
- 10
- 15
-
here roles are not fixed, it is not a static administrator can add roles and delete roles... how to make is dynamic here only fixed modules remaning everything changed like permission, groups, sub groups, roles, role module permissions, sub module permissions... help that one – sriram p May 02 '16 at 09:24
-
I do not get any clearer by your question, neither your comment. The links I provided you should be enough to get known with permissions. Maybe you could upload some code ? – JoeriShoeby May 02 '16 at 09:59
-
I read the upper documentation which one sent by you. But it was not helping me in my code . I have lots of code , so i can't send you that one. apologized for that . Can you guide me with any other document or ideas which can help me – sriram p May 02 '16 at 10:57
-
I have Modules, sub modules, roles, permissions, Role module permission, sub modules permission, Modules permission, User tables are interlinked with each other .How to manage the role -module permissions by using laravel. – sriram p May 02 '16 at 11:02
-
Like I said, all is provided in the links I gave you. Can't make it any clearer without code examples .. – JoeriShoeby May 02 '16 at 11:23
-
I have two controllers for two modules and each module have sub module example patient is one module in that sub modules are view profile, Feedback. and another module is booking in that sub module is booking an appointment and cancel an appointment. now modules and sub modules store in two different tables ,sub module methods like edit(patient), delete, create(patient Registeration) are store in another table – sriram p May 02 '16 at 11:43
-
I have two controllers for two modules and each module have sub module example patient is one module in that sub modules are view profile, Feedback. and another module is booking in that sub module are booking an appointment and cancel an appointment. now modules and sub modules store in two different tables,sub module methods like edit(patient), delete, create(patient Registration) are store in another table and it will have different level permissions roles, role module permission , sub module permission now backend was completed but dont know how to start front end – sriram p May 02 '16 at 11:54
-
means i am implementating middleware after how to control routes and methods i am trying to implement middleware but in middle i am not getting user permissions from previously mentioned tables... if permission and roles , role permissions are only these tables its easy but it have lot of tables and each table have different relationship with another table – sriram p May 02 '16 at 11:56
-
if i am getting user permissions atleast i am thinking after how to implement but here i am not getting user permissions from using all these tables in user model . I am trying using policy but it will work only two tables policy showing user and post tables ... now tell me how to implement this one first creating middle ware after if iam getting permissions i am doing route with manage but dont know how to start – sriram p May 02 '16 at 11:56
-
please sir help me – sriram p May 03 '16 at 10:23