Laravel编辑链接不';行不通
列表中的每个帖子都有Laravel编辑链接不';行不通,laravel,Laravel,列表中的每个帖子都有Edit链接 <a href="{{ URL::to('dashboard/post/' . $post->id . '/edit') }}" class="btn btn-default btn-edit-post">Edit</a> PostsController中的方法 public function edit($id) { $post = Post::findOrFail($id);
Edit
链接
<a href="{{ URL::to('dashboard/post/' . $post->id . '/edit') }}" class="btn btn-default btn-edit-post">Edit</a>
PostsController中的方法
public function edit($id)
{
$post = Post::findOrFail($id);
return view('dashboard.edit', compact('post'));
}
public function update($id, PostRequest $request)
{
$post = Post::findOrFail($id);
$post->update($request->all());
return redirect ('dashboard');
}
但在点击编辑按钮时,我得到了一个错误
RouteCollection.php第161行中的NotFoundHttpException:
怎么了?如何修复它?在路由文件中,您已经写过文章,在href post中
{{URL::to('dashboard/post/.$post->id./edit')}
路由::get('dashboard/posts/{id}/edit','PostsController@edit'); 在路由文件和href post中,您已经写了文章
{{URL::to('dashboard/post/.$post->id./edit')}
路由::get('dashboard/posts/{id}/edit','PostsController@edit'); 哎哟!。。非常感谢你!哎哟非常感谢你!
public function edit($id)
{
$post = Post::findOrFail($id);
return view('dashboard.edit', compact('post'));
}
public function update($id, PostRequest $request)
{
$post = Post::findOrFail($id);
$post->update($request->all());
return redirect ('dashboard');
}