2

I want to override an action method in laravel backpack without losing its functionality.

I am trying this

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();
  }
}

I want to set the Heading up with $this->crud->setHeading('some string', 'create'); into index method.

Any idea?

Thanks a lot

Eday Gonzalez
  • 310
  • 1
  • 2
  • 13
  • 1
    ListOperation isn't the parent ... what is this ListOperation, a trait? because your class isn't declaring that it uses a trait – lagbox Nov 24 '19 at 01:51

1 Answers1

4

One minute ago, I tried this and worked.

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();
  }
}


Thank you.

Eday Gonzalez
  • 310
  • 1
  • 2
  • 13