How to check user group for multiple methods at once? #598
-
Hi everyone! Shield has helped me so much in a project I'm working on right now but I'm not sure about the following 🤔 Right now I'm passing a check to all my methods inside my controller, for example: $user = auth()->user();
if ($user->inGroup('admin')) {
return view('management/home');
} else {
return redirect()->to(base_url('/'))->with('error', 'You have no permission to see this page...');
} This works great but I have to repeat myself for every method I have... Is there a way I can perform this check for multiple methods inside a controller? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, Thank you for your positive energy. The method you suggested works, but it is not the most correct method. We have 6 filters in Shield, in this regard you should use filter group. Everything you need is explained Authorizing via Routes
if you think it is still unclear let us know. |
Beta Was this translation helpful? Give feedback.
Hi, Thank you for your positive energy.
The method you suggested works, but it is not the most correct method.
We have 6 filters in Shield, in this regard you should use filter group.
Everything you need is explained Authorizing via Routes
if you think it is still unclear let us know.