dilfdo
4 years ago

at RouteCollection->methodNotAllowed(array('DELETE')) in RouteCollection.php line 206

Posted 4 years ago by dilfdo

im getting error when deleting

 success: function(data) {
                    var json_obj = $.parseJSON(data);//parse JSON

                    var output="<tr>";
                    for (var i in json_obj)
                    {
                        var url = "{{url('edit-shift')}}/"  + json_obj[i].id;
                        var del_url = "{{url('destroy-shift')}}/"  + json_obj[i].id;
                      
//                        $('#val2').val(shiftid);
                        output+=
                                "<td>" +  json_obj[i].id + "</td>"+
                                "<td>" +  json_obj[i].bus_no + "</td>"+
                                "<td>" +  json_obj[i].shift_no + "</td>"+
                               "<td>" +  json_obj[i].shift_start_time + "</td>"+
                               "<td>" +  json_obj[i].shift_end_time + "</td>"+
                               "<td>" +  json_obj[i].run_type + "</td>"+
                                "<td><a data-toggle='modal'  data-target='#myModal3' href='" + url +"' >EDIT</a><a href='" + del_url +"' >DEL</a></td>";


                        output+="</tr>";

                    }


                    $('#span').html(output);



routes


Route::delete('destroy-shift/{id}', ['as' => 'destroy-shift', 'uses' => 'TimesheetsController@destroy']);

controller

``

public function destroy($id)
{
    $shift = Shifts::findOrFail($id);

    $shift->delete();

    return "done";
}

Please sign in or create an account to participate in this conversation.