I have got a form with a delete button which I see on the console that it's sending a delete request.
jquery.js:4 DELETE http://laravel.com/painel/player/53 500 (Internal Server Error)
and my route is:
Route::resource('painel/player','PlayerController');
| DELETE | painel/player/{player} | painel.player.destroy | App\Http\Controllers\PlayerController@destroy |
and my method destroy is as below:
public function destroy($id)
{
$player = Player::where('id_player', '=', $id)->first();
$player->delete();
$player = array(
'users' => Player::all(),
'refresh' => true
);
return View::make('painel.player.show', $player);
}
EDIT: I forgot to mention the ajax:
$( document ).on('click', '.solsoConfirm', function(){
$("#solsoDeletForm").prop('action', $(this).attr('data-href'));
});
$( document ).on('click', '.solsoDelete', function(e){
e.preventDefault();
var solsoSelector = $(this);
var solsoFormAction = $('#solsoDeletForm').attr('action');
$.ajax({
url: solsoFormAction,
type: 'delete',
cache: false,
dataType: 'html',
success:function(data) {
$('#solsoDeleteModal').modal('hide');
$('#ajaxTable').html(data);
$('#countClients').text( $('.solsoTable').attr('data-all') );
$.growl.notice({ title: solsoSelector.attr('data-message-title'), message: solsoSelector.attr('data-message-success') });
$('.solsoTable').dataTable();
}
});
return false;
});
routes.php
code as well. – Ahmad Baktash Hayeriroutes.php
full code to the question? – Ahmad Baktash Hayeriroutes.php
), so can you post its content as well as full controller code for the destroy method? – Ahmad Baktash Hayeri