Skip to content
Discussion options

You must be logged in to vote

Hey @algodoncin

Middleware is just one stack layer before the controller so you have two options:

  • Do not use Route::crud() and create all the routes manually, so you can apply middleware to each route.
  • Leave it as is, and do the user verification at controller level.

For the second option, you can just add into your setup() method:

if(backpack_user()->hasRole('user')) { // or whatever you are using to check the user type.
    CRUD::denyAccess(['update', 'delete', 'show']); // this will prevent users with type "user", from accessing update, delete and show operations.
}

Here are the docs for CRUD access functions: https://backpackforlaravel.com/docs/6.x/crud-api#access

Let me know if tha…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karandatwani92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants