我正在尝试将变量 $id 传递给路由文件中的控制器函数。
以下是各个文件的片段:
路由.php
Route::get('/news-post/{$id}', 'BlogController@getPost');
博客控制器.php
public function getPost($id)
{
$post = \App\blog::find($id);
if($post == NULL){
App::abort(404);
}
return View('webpages.news-post',['title'=>$post['title'],'post'=>$post]);
}
我 在 RouteCollection.php 第 161 行收到 NotFoundHttpException:
我已尝试搜索原因,但找不到任何原因。