So you want to add a new operation to the UserCrudController, the one that our PermissionManager addon provides? Here’s how you can do...
So you want to add a new operation to the UserCrudController, the one that our PermissionManager addon provides? Here’s how you can do that.
Let’s go ahead.
We will create a UserCrudController extending Backpack Permission Manager’s UserCrudController
. That way, we keep getting all updates to the package.
//app/Http/Controllers/Admin/UserCrudController.php
<?php
namespace App\Http\Controllers\Admin;
use Backpack\PermissionManager\app\Http\Controllers\UserCrudController as CrudController;
class UserCrudController extends CrudController
{
}
Then in AppServiceProvider, we'll tell Laravel to use our new UserCrudController, instead of the one provided by Permission Manager:
//app/Providers/AppServiceProvider.php
public function register(){
+ $this->app->bind(
+ \Backpack\PermissionManager\app\Http\Controllers\UserCrudController::class,
+ \App\Http\Controllers\Admin\UserCrudController::class
+ );
}
Final Step, use your operation inside UserCrudController
. Here, I'm using EmailOperation
created in our previous tutorial.
class UserCrudController extends CrudController{
+ use \App\Http\Controllers\Admin\Operations\EmailOperation;
}
That’s it, really.😀
Thanks for reading 😀 – I hope you learned something new. Let us know what you think in the comments below.
Subscribe to our "Article Digest". We'll send you a list of the new articles, every week, month or quarter - your choice.
What do you think about this?
Wondering what our community has been up to?