Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

Repeat same query every time when i check the permisson ? #870

Open shankhadevpadam opened 7 years ago

shankhadevpadam commented 7 years ago

My problem is, i have the main menu and the menu item is accessible when such permission is assign to respective role. So my question is when i used $user->can() to check the permission for every menu item which run same query every time

select `permissions`.*, `permission_role`.`role_id` as `pivot_role_id`, `permission_role`.`permission_id` as `pivot_permission_id` from `permissions` inner join `permission_role` on `permissions`.`id` = `permission_role`.`permission_id` where `permission_role`.`role_id` = '1'

for example i have 5 menu item then this query run 5 times which take extra time to load the page.

vagkaefer commented 6 years ago

I'm new with the entrust, but the "User ability" does not solve your problem? https://github.com/Zizaco/entrust#user-ability

Or you can create Roles, and create menus for each Role, this will shorten the loading time... I believe that you may have to see your problem differently, in relation to the structure of the entrust

Zizaco commented 6 years ago

I will be looking at this

mkuzmych commented 6 years ago

@vagkaefer User ability - not what user need! Questions about multiple selects from database.

dneykov commented 6 years ago

Any news on this?