use DELETE method in route with Laravel 5.4

前端 未结 3 1310
眼角桃花
眼角桃花 2020-12-09 09:25

I\'m working on a Laravel (v 5.4) project and i did the CRUD to manage categories. Currently, i can create a new category and i would be able to delete.

I created th

3条回答
  •  长情又很酷
    2020-12-09 09:44

    If you click on an url it will always be a GET method.

    Since you wish to define it as DELETE, you should remake it into a post form and add

    
    

    in it. Like replace:

    
        
    
    

    with:

    Same goes for PUT request.

    Since Laravel 5.1 method_field:

    {!! method_field('delete') !!} {!! csrf_field() !!}

    Since Laravel 5.6 just with @ tag:

    @method('delete') @csrf

提交回复
热议问题