使用某些前缀时,我无法获取资源的索引路由,
当我的路线是这样时:
Route::resource('subjects', 'SubjectController')->middleware('auth:admin');
我得到了这条路线清单:
| subjects | subjects.index
| subjects | subjects.store
| subjects/create | subjects.create
| subjects/{subject} | subjects.update
| subjects/{subject} | subjects.destroy
| subjects/{subject} | subjects.show
| subjects/{subject}/edit | subjects.edit
但是当我添加这样的前缀时:
Route::prefix('admin')->group(function () {
Route::resource('subjects', 'SubjectController')->middleware('auth:admin');
});
索引路由消失,路由列表变为:
| admin/subjects | subjects.store
| admin/subjects/create | subjects.create
| admin/subjects/{subject} | subjects.update
| admin/subjects/{subject} | subjects.destroy
| admin/subjects/{subject} | subjects.show
| admin/subjects/{subject}/edit | subjects.edit
答案 0 :(得分:-1)
得到解决方案。实际上,我的web.php中还有另一条路线(“主题”)。我需要删除它,因为它们都在碰撞。