我在我的应用程序中添加了数据表,我希望使每个条目的ID成为指向编辑页面的超链接,以便用户能够编辑其帖子。但是我收到404 Not Found错误
我尝试更新路由文件,但没有得到正确的结果,我无法弄清楚自己在做什么错
我的网络php文件具有:
Route::get('edit','PostsController@edit');
我的帖子的索引是
<table class="display" id="postsTable">
<thead>
<tr>
<td>ID</td>
<th>Title</th>
<th>Slug</th>
<th>Subtitle</th>
<th>Content</th>
<th>Category</th>
</tr>
</thead>
<tbody>
@foreach($posts as $post)
<tr>
<td><a href="edit/{{$post->id}}">{{$post->id}}</a></td>
<td>{{$post->title}}</td>
<td>{{$post->slug}}</td>
<td>{{$post->subtitle}}</td>
<td>{{$post->content}}</td>
<td>{{$post->category_id}}</td>
</tr>
@endforeach
</tbody>
而PostsController编辑功能是:
public function edit($id)
{
$posts = Post::findOrFail($id);
return view('posts.edit',compact('posts'));
}
我尝试在线搜索并尝试一些路线,但我设法使事情变得更糟,而不是解决了我的问题。任何帮助深表感谢!