Closed jrbecart closed 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 channels:
backpack-for-laravel
tag;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
@jrbecart at first I thought this would be a good idea. And in theory it shouldn't be difficult at all to achieve:
config/backpack/crud.php
config file, for the revise
operation;But then I though - you should be able to do the exact same inside a setupReviseOperation()
method. Backpack will automatically call it if it's there. And now that I think of it, it should be pretty easy and customizable over there to check the combination of user/route/permission and abort if something's not ok. MUCH easier than bloating the package with this additional logic. So something like this should do it:
public function setupReviseOperation() {
// if route operation is `revise` AND
// the called route name ends with `restoreRevision` AND
// the user doesn't have the permission to do this
// TODO: abort
}
Let me know what you think. Cheers!
@tabacitu Thanks! I was thinking at the same solution and I will probably doing it that way. It's just that I have many controllers... :(
My other solution was to do it in custom.php
but I was unable to use the wildcard in the route so instead of overriding all routes I will do it in all my controllers.
// I attempted to replace myroute with wildcard such as {any}, {any?}, {any:.*}
// to override all routes at once but with no luck
Route::post('myroute/{id}/revise/{revisionId}/restore', function () {
abort(404);
});
Anyway you are right that's probably the easiest way and this will avoid to bloat the package.
👍 if you need it across many CrudControllers, you can:
ReviseOperationRestoreOnlyIfPermission
ReviseOperation
traitPersonally I'd put that inside app/Http/Controllers/Admin/Operations
but to each his own.
Hope it helps!
Feature Request
What's the feature you think this package should have?
Possibility to remove the /restore route or add another operation name to manage permission differently from the list route. Be allowed to use permission.
Have you already implemented a prototype solution, for your own project?
No
Do you see this as a core feature or an add-on?
Yes