Properly implemented deletion of records?

Learning Laravel, just started
Make a simple admin area for one page.
Not found a example how it is possible byloby to do deletion of records
Made up :)
Most likely there is a more elegant solution to this issue
Can point out errors? Thank you

Part Of The Controller
class Controller extends SlideController
{
 public function destroy($id){
Slide::destroy($id);
 return redirect()->back();
}
}


<!-- Do delete records -->
<div id="url" data-url="{{ $urlDel = Route::getCurrentRoute()->getPath() }}">
 {{ Form::open(array('route' => array('admin.slides.destroy', 0), 'method' => 'delete')) }}
 {{ Form::close() }}
</div>
the <script>
$('span.del').click(function(){
 var getId = $(this).data('id');
 var actionUrl = '/' + $('#url').data('url') + '/'+getId;
 var data = $('#url-form').serialize();

$.ajax({
 type: 'POST',
 url: actionUrl,
 data: data,
 success: function(data) {
 // 'tr#row'+getId string ID partisan aydishnik in the template
$('tr#row'+getId).fadeOut('slow');
},
 error: function (data) {
 alert('there was an unfortunate mistake. The entry was not removed. Try again please'+data);
}
});

 //$('#url-form').attr('action', actionUrl).submit();
})
</script>
<!-- Do delete records -->
July 8th 19 at 11:55
1 answer
July 8th 19 at 11:57
- What form? There it is absolutely not necessary
- Why return redirect()->back(); if the request is via ajax?
- Removal decided to put the confirmation (the same alert('are you sure You want to destroy the world?'))
- It is better to use POST and DELETE (or emulate POST + hidden field _method="DELETE")
-
are formed in the form of hidden input
_token read somewhere that is necessary
how to get it otherwise, don't know(but probably do)
and how to pass it? just in data ???

- larue_Jerde commented on July 8th 19 at 12:00
in head to output a meta tag with {{ cstf_token() }} and then read it from there.
To pass data: {a: b} - nickolas commented on July 8th 19 at 12:03

Find more questions by tags Laravel