I have implemented Entrust Roles for ACL layer. Now I'm planning to automate the permission check for each request so that, each time I don't have to write the permission for the user roles.
eg. I have company resource, and user role as 'admin', he can only view company and another user role as 'super' can manage company. In database I had provided them appropriate permissions but in the middleware to check there permission, I am planning to achieve this:
if url goes: localhost/company/create - In DB permission will be of create_company and current logged in user will be checked based on this permission.
$user->can('create_company') OR
$user->can(['create_company', 'view_company']);
Que1: Is this possible to achieve this with middle ware, where route names eg.company.create, company.show are accessible ( so that dots are replaced with '_' and we can check permission) ? How?
Que2: Is this nice approach to achieve automatic role checking or there is some other better approach.
Any help/suggestion would be highly appreciated.