title: How to delete checked items with one delete button
body: <p>I want to make a delete button that deletes the checked items. Means one  master button to delete all the checked items. I made a master checkbox that checks all the values. Now I want to make a master button that would delete the checked values. Here is my code. I am new in laravel please help me. Sorry for my bad english.  </p>
  
  <pre><code>@extends('footer')
  @extends('header')
  
  @section('body')
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Retrieve data|Std view&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="{{ asset('public/css/style.css') }}"&gt;
  &lt;link rel="stylesheet" type="text/css" href="{{ asset('public/css/bootstrap.css') }}"&gt;
  &lt;script type="text/javascript" src="{{ asset('public/js/jQuery.js') }}"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      @if(session()-&gt;has('success'))
      &lt;div class="alert alert-success"&gt;
          &lt;h3&gt; {{ session()-&gt;get('success') }} &lt;/h3&gt;
      &lt;/div&gt;
  
      @endif 
  
  &lt;div class="container"&gt;
      &lt;form action="" method=""&gt;
      &lt;input type="hidden" name="_token" value="&lt;?php echo csrf_token(); ?&gt;"&gt;
  
      &lt;h2 style="color: green"&gt;This Is View Form&lt;/h2&gt;
      &lt;a href = "insert" class="btn btn-primary"&gt;Add New&lt;/a&gt;
  
  //HERE IS MY MASTER DELETE BUTTON.
      &lt;button type="submit" class="btn btn-danger"  &gt;Delete&lt;/button&gt;&lt;br&gt;&lt;br&gt;
  
  
      &lt;table border="1" id="customers"&gt;
          &lt;tr&gt;
              &lt;th&gt;
  //Here is my checkbox inside the loop.
      &lt;input type="checkbox" id="master" onchange="checkall(this);"&gt; All
              &lt;/th&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Email&lt;/th&gt;
              &lt;th&gt;Update&lt;/th&gt;
              &lt;th&gt;Delete&lt;/th&gt;
  
          &lt;/tr&gt;
  
          @foreach($data as $value)
          &lt;tr&gt;
  
              &lt;td&gt;
                  &lt;input type="checkbox" class="sub_chk_{{ $value-&gt;id }}"  value="{{ $value-&gt;id }}"&gt;
              &lt;/td&gt;
              &lt;td&gt;{{ $value-&gt;name }}&lt;/td&gt;
              &lt;td&gt;{{ $value-&gt;email }}&lt;/td&gt;
  &lt;td&gt;&lt;a href="edit/{{$value-&gt;id}}" class="btn btn-primary" &gt;Edit&lt;/a&gt;&lt;/td&gt;
  
  //THIS DELETE BUTTON FOR SINGLE DELETE FUNCTION
  
  &lt;td&gt;&lt;a href="delete/{{$value-&gt;id}}" onclick='ConfirmDelete()' class="btn btn-danger" &gt;Delete&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          @endforeach
      &lt;/table&gt;
      &lt;/form&gt;&lt;br&gt;
  
      {{ $data-&gt;links() }}
  
  &lt;/div&gt;  
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  @endsection
  
  &lt;script&gt;
  
      function checkall(obj) {
          var selectedIds = [];
          if(obj.checked){
       $('input:checkbox').not(obj).prop('checked', 'checked');
       $("input:checkbox").each(function(){
          var $this = $(this);
  
      if($this.is(":checked")){
          selectedIds.push($this.attr("value"));
      console.log(selectedIds);
      }
       })
          }
          else{
       $('input:checkbox').prop('checked',false);
          }
   }
  
  function ConfirmDelete()
  {
    var x = confirm("Are you sure you want to delete?");
    if (x)
        return true;
    else
      event.preventDefault();
      return false;
  }
  
  
  &lt;/script&gt;
  </code></pre>