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

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

I have a link



        
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 18:16

    In case someone came here to find how to replace standard laravel form for delete, from button in it to link, you can just replace:

    {!! Form::open(['method' => 'DELETE', 'route' => ['tasks.destroy', $task->id],'onsubmit' => 'return confirm("Are you sure?")', 'id'=>'himan']) !!}
    
        {!! Form::submit('Delete') !!}
    
    {!! Form::close() !!}
    

    TO

    {!! Form::open(['method' => 'DELETE', 'route' => ['tasks.destroy', $task->id],'onsubmit' => 'return confirm("Are you sure?")', 'id'=>'himan']) !!}
    
        Delete
    
    {!! Form::close() !!}
    

    Just replace button with simple but with onclick attribute to submit the form!

提交回复
热议问题