Override CRUD views

后端 未结 3 1038
悲&欢浪女
悲&欢浪女 2021-02-09 08:02

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

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-09 08:56

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

提交回复
热议问题