如何在不丢失其功能的情况下覆盖 backpack-for-laravel 中的操作方法

How to override an action method in backpack-for-laravel without losing its functionality

我想覆盖 laravel 背包中的一个动作方法而不失去它的功能。

我正在尝试这个

use Backpack\CRUD\app\Http\Controllers\Operations\ListOperation\ {index as traitIndex };

use Backpack\CRUD\app\Http\Controllers\CrudController;

class ApplicationCrudController extends CrudController
{

  public function setup() {...}

  // trying to override using the functionality
  public function index() {
    parent::traitIndex();
  }
}

我想用 $this->crud->setHeading('some string', 'create'); 设置标题。进入索引方法。

有什么想法吗?

非常感谢

一分钟前,我尝试了这个并成功了。

use Backpack\CRUD\app\Http\Controllers\Operations\ListOperation\  // I deleted this {index as traitIndex };

use Backpack\CRUD\app\Http\Controllers\CrudController;

class ApplicationCrudController extends CrudController
{

    // Add this
    use ListOperation {
        index as traitIndex;
    }

  public function setup() {...}

  // trying to override using the functionality
  public function index() {
    // delete this parent::traitIndex();
    // and add this
    return $this->traitIndex();
  }
}


谢谢。