Laravel-Backpack / PermissionManager

Admin interface for managing users, roles, permissions, using Backpack CRUD
http://backpackforlaravel.com
Other
527 stars 168 forks source link

manage permissions automatically for essential CRUD operations #234

Closed webdesign7 closed 4 years ago

webdesign7 commented 4 years ago

Is there an easy way of managing access to essential crud operations , currently I am doing like this in setup() function .. but I wonder if there is a way to do this simpler , without repeating the same for each controller .. any ideas ?

`if ( !backpack_user()->hasPermissionTo('delete') )
    {
        $this->crud->denyAccess('delete');
    }

    if ( !backpack_user()->hasPermissionTo('create') )
    {
        $this->crud->denyAccess('create');
    }

    if ( !backpack_user()->hasPermissionTo('update') )
    {
        $this->crud->denyAccess('update');
    }`
welcome[bot] commented 4 years ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

tabacitu commented 4 years ago

@webdesign7 you should be able to do this inside a PHP trait, then just re-use that trait on all Controllers where you want this.

support[bot] commented 4 years ago

Oups!

Looks like this is a support request, not a bug/feature. Could you please repost on StackOverflow, using the backpack-for-laravel tag?

Background: Here at Backpack we use Github Issues only for tracking bugs and features, not individual implementation issues. This helps a lot in keeping our focus on improving Backpack. Thanks a lot for understanding!

Here are all the Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or StackOverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

PS. In case I mistakenly closed your issue, yell :-) I'm a robot, I make mistakes.