编辑方法中的Laravel漂亮url

编辑方法中的Laravel漂亮url,laravel,laravel-route,form,Laravel,Laravel Route,Form,有人能告诉我,当我试图编辑我的帖子时,我怎么还能有漂亮的URL?我有slug等,但对于编辑方法,我们需要使用GET | HEAD,这意味着我们将有如下内容: 与此相反: 以下是代码的一部分: <td> <form action="{{ route('posts.edit', $post->slug) }}" method="get"> @csrf <button type="submit

有人能告诉我,当我试图编辑我的帖子时,我怎么还能有漂亮的URL?我有slug等,但对于编辑方法,我们需要使用GET | HEAD,这意味着我们将有如下内容:

与此相反:

以下是代码的一部分:

<td>
  <form action="{{ route('posts.edit', $post->slug) }}" method="get">
    @csrf
    <button type="submit" name="btn-editPost" class="btn btn-info btn-sm" style="color: white;">Edit</button>
  </form>
</td>

@csrf
编辑
注意:slug设置正确,这不是问题:)

实际上您不需要,如果您只需删除
@csrf
,它就会工作

或者,更改您的代码:

<td>
   <form action="{{ route('posts.edit', $post->slug) }}" method="get">
      @csrf
      <button type="submit" name="btn-editPost" class="btn btn-info btn-sm" style="color: white;">Edit</button>
   </form>
<td>

@csrf
编辑
对,


实际上,您不需要,只要删除
@csrf
,它就可以工作了

或者,更改您的代码:

<td>
   <form action="{{ route('posts.edit', $post->slug) }}" method="get">
      @csrf
      <button type="submit" name="btn-editPost" class="btn btn-info btn-sm" style="color: white;">Edit</button>
   </form>
<td>

@csrf
编辑
对,



method=“get”
更改为
method=“post”
并将您的路线
get
更改为
post
我使用资源路线更改
method=“get”
method=“post”
并将您的路线
get
更改为
post
我使用资源路线