Are you sure want to delete?


I have on my delete function a message for confirmation of delete when i put ok nothing is done

Function from controller

public function destroy($id)
{

    $client =client::find($id);
    $client->delete();
    return redirect('client');
}

view client

<form action="{{url ('client/'.$client->id)}}" method="post">
                            {{csrf_field()}}
                            {{method_field('DELETE')}}
                            <a href="{{url('client/'.$client->id.'/show')}}" 
 class="btn btn-default btn-sm">Details</a>
                            <a href="{{url('client/'.$client->id.'/edit')}}" 
 class="btn btn-primary btn-sm">Editer</a>
                              <a class="btn btn-danger btn-sm" title="Delete"
                           href="javascript:if(confirm('Are you sure want to 
 delete?')) $('#frm_{{$client->id}}').submit()">
                            Supprimer
                        </a>
                        </form>

Image


Answers:


in your route file just change like this

Route::get('/client/{id}/delete', 'ClientController@destroy');

in your view

<a href="{{url ('client/'.$client->id.'/delete')}}" onclick="return confirm('Are you sure?')">Delete</a>