我刚刚在Laravel项目中安装了Backpack。我按照步骤操作,但是出现404错误。
class PostCrudController extends CrudController
{
public function setup()
{
/* CrudPanel Basic Information */
$this->crud->setModel('App\Models\Post');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/post');
$this->crud->setEntityNameStrings('post', 'posts');
/* CrudPanel Configuration */
// TODO: remove setFromDb() and manually define Fields and Columns
$this->crud->setFromDb();
// add asterisk for fields that are required in PostRequest
$this->crud->setRequiredFields(StoreRequest::class, 'create');
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');
}
}
custom.php路由
Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
'namespace' => 'App\Http\Controllers\Admin',
], function () { // custom admin routes
CRUD::resource('Post', 'PostCrudController');
}); // this should be the absolute last line of this file
有人可以帮助我吗?