Override CRUD views

Sybrand Hoeksma picture Sybrand Hoeksma · Sep 2, 2016 · Viewed 8k times · Source

I would like to override the CRUD views of the Laravel Backpack CRUD package, because I want to make small changes to the layout. But obviously I don't want to change the CRUD package itself. Is there an elegant to do this?

Answer

Sachin picture Sachin · Sep 2, 2016

In your controller which is extending Backpack\CRUD\app\Http\Controllers\CrudController you need to override the method like index,create,edit which you want to change. All method are in-

Backpack\CRUD\app\Http\Controllers\CrudController

All the methods are here. You need to change here

 public function index()
{
    $this->crud->hasAccessOrFail('list');

    $this->data['crud'] = $this->crud;
    $this->data['title'] = ucfirst($this->crud->entity_name_plural);

    // get all entries if AJAX is not enabled
    if (! $this->data['crud']->ajaxTable()) {
        $this->data['entries'] = $this->data['crud']->getEntries();
    }

    // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
    // $this->crud->getListView() returns 'list' by default, or 'list_ajax' if ajax was enabled
    return view('your_view_name', $this->data);
}