Extending Backpack Admin ArticleCrudController

287 views Asked by At

I am trying to extend Backpack\NewsCRUD\app\Http\Controllers\Admin\ArticleCrudController so that I can add a new field. But it does not show a new field. What am I doing wrong here?

namespace App\Http\Controllers\Admin;

use Backpack\NewsCRUD\app\Http\Controllers\Admin\ArticleCrudController as OriginalArticleCrudController;

class ArticleCrudController extends OriginalArticleCrudController
{

    public function __construct()
    {
        parent::__construct();

        $this->crud->addField([   
            'name' => 'thumb',
            'label' => 'Thumb',
            'type' => 'browse',
        ]);
    }

}

It seems the link in resources/vendor/backpack/base/inc/sidebar.php is not pointing to this new ArticleCrudController.

<ul class="treeview-menu">
   <li><a href="{{ url('admin/article') }}"><i class="fa fa-newspaper-o"></i> <span>Articles</span></a></li>
   <li><a href="{{ url('admin/category') }}"><i class="fa fa-list"></i> <span>Categories</span></a></li>
   <li><a href="{{ url('admin/tag') }}"><i class="fa fa-tag"></i> <span>Tags</span></a></li>
</ul>
1

There are 1 answers

0
shin On

I needed to add a route to routes/web.php to make it work.

// Admin Interface Routes
Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function()
{
  ...
  ...
  // Backpack\NewsCRUD
    CRUD::resource('article', 'Admin\ArticleCrudController');
});