话题的资源路由为什么不需要create和edit?
在web路由页面需要create和edit
Route::resource('topics', 'TopicController', [
'only' => [
'index', 'show', 'create', 'store', 'update', 'edit', 'destroy'
]
]);
为什么api路由页面不需要这两个东西了?手机端点击“新建话题”按钮后,不需要访问 route(‘topics.create’) 指向的url吗?
// 游客可以访问话题列表、详情
Route::resource('topics', 'TopicsController')->only([
'index', 'show'
]);
// 需要登录后才可以访问的接口
Route::middleware('auth:api')->group(function() {
// 以下不含 create、edit
Route::resource('topics', 'TopicsController')->only([
'store', 'update', 'destroy'
]);
});
推荐文章: