更新时间:2023-11-17 18:34:40
问题是您的create
路由在常规posts/{id}
路由之后列出. Laravel将/posts/之后的每个段都作为ID处理,并忽略特殊" create
路由.
The problem is that your create
route is listed after the general posts/{id}
route. Laravel handles every segment after the /posts/ as an id and ignores the "special" create
route.
像这样交换这两行:
Route::get('/posts/create', 'PostController@showForm');
Route::get('/posts/{id}', 'PostController@showById');
此外,我建议您使用资源控制器,这会使您路由使生活变得更轻松!
Furthermore I'd suggest you to use resource controllers which makes your life a bit easier with routing!