title: sweetalert delete confirm laravel
body: <p>I have a problem in <strong>laravel</strong> for confirming the post delete by <strong>sweetalert</strong></p>
  
  <pre><code>&lt;script&gt;
          !function ($) {
          "use strict";
          var SweetAlert = function () {
          };
          //examples 
          SweetAlert.prototype.init = function () {
  
              $('.sa-remove').click(function () {
                  swal({
                      title: "are u sure?",
                      text: "lorem lorem lorem",
                      type: "error",
                      showCancelButton: true,
                      confirmButtonClass: 'btn-danger waves-effect waves-light',
                      confirmButtonText: "Delete",
                      cancelButtonText: "Cancel",
                      closeOnConfirm: true,
                      closeOnCancel: true
                  },
                  function(){
                      window.location.href = "{{ route('panel.posts.remove',$post-&gt;id) }}";
                  });
              });
          },
          //init
          $.SweetAlert = new SweetAlert, $.SweetAlert.Constructor = SweetAlert
  }(window.jQuery),
  
  //initializing 
      function ($) {
          "use strict";
          $.SweetAlert.init()
      }(window.jQuery);
  &lt;/script&gt;    
  </code></pre>
  
  <p>But I have a <code>foreach</code> in the view and it just passes last <code>foreach</code> post <code>id</code> and when I want to delete for example second post in the table, last one deletes!</p>
  
  <p>this is the table:</p>
  
  <pre><code>             &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;ID&lt;/th&gt;
                      &lt;th&gt;Title&lt;/th&gt;
                      &lt;th&gt;Body&lt;/th&gt;
                      &lt;th&gt;Author&lt;/th&gt;
                      &lt;th&gt;Operations&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  @foreach($posts as $post)
                  &lt;tr&gt;
                      &lt;td&gt;{{ $post-&gt;id }}&lt;/td&gt;
                      &lt;td&gt;{{ $post-&gt;title }}&lt;/td&gt;
                      &lt;td&gt;{{ $post-&gt;body }}&lt;/td&gt;
                      &lt;td&gt;{{ $post-&gt;user-&gt;name }}&lt;/td&gt;
                      &lt;td&gt;
                           &lt;a href="#" class="sa-remove"&gt;&lt;button class="wave-effect btn btn-danger btn-bordred wave-light"&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/a&gt;
                      &lt;/td&gt; 
                  &lt;/tr&gt;
                  @endforeach
              &lt;/tbody&gt;
  </code></pre>
  
  <p>and I'm new in this of course!</p>