I'm using jQuery modal box for delete function. But I'm getting this error when clicking yes button on modal box
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
Here is my view which I load the data modal popup
<a data-toggle='modal'
data-target='#delete-user-warning-data-{{ $company1->id}}' href="{{url('delete-warning', $company1->id)}}">
{!! Form::open(['method' => 'DELETE', 'route' => ['delete-warning', $company1->id],'class' => 'form-del']) !!}
<button type="button" class="btn btn-dadnger" aria-label="Center Align" data-toggle="modal">
<i class="fa fa-trash-o"></i>
</button>
{{--<button type="submit" id="del" class="btn"--}}
{{--onclick="return confirm('Are you sure you want to permnently delete the license code? If the code is currently being used by a book, it will be in in-accessible until the user entries a new code.')">--}}
{{--<span class="glyphicon glyphicon-minus-sign"></span>--}}
{{--</button>--}}
{!! Form::close() !!}
</a>
<!-- DELETE -->
<div class="modal fade" id="delete-user-warning-data-{{ $company1->id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title text-center" id="myModalLabel">Are you sure you want to delete ?</h4>
</div>
<div class="modal-body">
<p class="center-block text-center">{{ $company1->id}}</p>
<div class="prompt-center-area">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="closeModel();">No</button>
<button type="submit" class="btn btn-primary" >Yes</button>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
This is the route
Route::delete('delete-warning/{id}', ['as' => 'delete-warning', 'uses' => 'CodesController@destroy']);
and this is my controller for delete function
public function destroy($id)
{
try{
$Code = Codes::findOrFail($id);
$Code->delete();
return redirect()->back();
}catch(\Exception $e){
return redirect()->back();
}
}
Please advice me how fix this issue