CRUD Laravel 5 how to link to destroy of Resource Controller?

后端 未结 10 2191
迷失自我
迷失自我 2020-12-15 17:27

I have a link



        
10条回答
  •  我在风中等你
    2020-12-15 17:56

    You need to send a DELETE request instead of a GET request. You can't do that with a link, so you have to use an AJAX request or a form.

    Here is the generic form method:

    If you're using Laravel 5.1 or later then you can use Laravel's built-in helpers to shorten your code:

    {{ method_field('DELETE') }} {{ csrf_field() }}

    If you're using Laravel 5.6 or later then you can use the new Blade directives to shorten your code even further:

    @method('DELETE') @csrf

    You can read more about method spoofing in Laravel here.

提交回复
热议问题