1

can someone tell me how can I still have pretty URL when trying to edit my post? I have slugs etc but for edit method, we need to use GET|HEAD which means we will have something like this:

www.our-domen.com/admin/posts/this-is-my-post-for-edit/edit?_token=0GXpk4oaLdGy8YOdp0591ogAOIHF89ZCciWk79h&btn-editPost=

Instead of this:

www.our-domen.com/admin/posts/this-is-my-post-for-edit/edit

Here is the part of the code:

<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>

Note : slugs are set up correctly, it is not a problem :)

STA
  • 30,729
  • 8
  • 45
  • 59
Sead Silajdzic
  • 298
  • 1
  • 4
  • 21

1 Answers1

0

You don't need the actually, if you just delete @csrf, it will work.

Or, change your code :

<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>

To,

<td>
   <a href="{{ route('posts.edit', $post->slug) }}" type="button" class="btn btn-info btn-sm" style="color: white;">Edit</a>
</td>
STA
  • 30,729
  • 8
  • 45
  • 59