artisticre
4 months ago
555
5
Laravel

Delete Modal Not Deleting

Posted 4 months ago by artisticre

When I click the delete button my modal works and gives me the message and another delete button in a form. When I click delete, it does nothing. What am I doing wrong?

Modal Link

 <a href="javascript:;" data-toggle="modal" onclick="deleteData({{$row->id}})" 
data-target="#DeleteModal" class="btn btn-xs btn-danger">Delete</a>

Modal

<div id="DeleteModal" class="modal fade text-danger" role="dialog">
   <div class="modal-dialog ">
     <!-- Modal content-->
     <form action="{{route('registrar.pilgrim.delete', $row->id)}}" id="deleteForm" method="post">
         <div class="modal-content">
             <div class="modal-header bg-danger">
                 <button type="button" class="close" data-dismiss="modal">&times;</button>
                 <h4 class="modal-title text-center">DELETE CONFIRMATION</h4>
             </div>
             <div class="modal-body">
                 {{ csrf_field() }}
                 {{ method_field('DELETE') }}
                 <p class="text-center">Are You Sure Want To Delete ?</p>
             </div>
             <div class="modal-footer">
               
                     <button type="button" class="btn btn-success" data-dismiss="modal">Cancel</button>
                     <button type="submit" name="" class="btn btn-danger" data-dismiss="modal" onclick="formSubmit()">Yes, Delete</button>
              
             </div>
         </div>
     </form>
   </div>
  </div>

Delete Route

Route::get('pilgrim-delete/{id}','[email protected]')->name('registrar.pilgrim.delete');

Delete Controller

public function pilgrimDestroy($id)
    {
       
        
        DB::delete('delete from pilgrimapp where id = ?',[$id]);
        

        return redirect()->route('registrar-dashboard');
    }

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