Support the ongoing development of →
Authorization Authentication Architecture
Last updated by @ajax30 1 year ago.

You have to define your route like this

Route::get('/users', [UsersContoller::class, 'index'])->middleware('checkUserPermissions:view-users');

And you have to update your middleware handle function to

public function handle(Request $request, Closure $next, $permission)
        // Check user permissions
        if (!$this->hasPermissionTo($permission)) {
            return redirect('/')->with('error', 'You do not have permission to access to this section of the application');
        return $next($request);

Hope, this will help you.

Last updated by @faisal 2 years ago.

Sign in to participate in this thread!


Your banner here too?

Razvan ajax30 Joined 2 Oct 2021


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.