扩展背包管理ArticleCrudController

时间:2016-12-25 00:59:30

标签: backpack-for-laravel

我正在尝试扩展Backpack \ NewsCRUD \ app \ Http \ Controllers \ Admin \ ArticleCrudController以便我可以添加一个新字段。但它并没有显示出新的领域。我在这里做错了什么?

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',
        ]);
    }

}

resources/vendor/backpack/base/inc/sidebar.php中的链接似乎没有指向这个新的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 个答案:

答案 0 :(得分:1)

我需要添加一条到routes/web.php的路线才能使其正常运行。

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