phplaravellaravel-10laravel-backpack

how to change field names in preview page (/admin/user/{id}/show)?


I just installed Laravel Backpack Pro and added an isAdmin column to my Users column / model.

I've updated app/Http/Controllers/Admin/UserCrudController.php so that when editing a user and viewing the list of all users isAdmin shows up as Admin but how do I do that in the user preview page (/admin/user/{id}/show)?

For /admin/user/{id}/edit I modified setupUpdateOperation() to include this:

CRUD::field([
    'name' => 'isAdmin',
    'label' => 'Admin',
]);

For /admin/user I modified setupListOperation() to include this:

CRUD::column('isAdmin')->label('Admin');

But idk what function I'd need to modify to make the user preview page's behavior change. Initially I thought that setupListOperation() might do that page as well but, after modifying it, it turns out that that's not the case.

Any ideas?


Solution

  • you need to use ShowOperation trait in your UserCrudController

    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;

    then you can override the setupShowOperation() method the same as you did in setupListOperation() and setupUpdateOperation()