title: Delete method with Sweet Alert in Laravel
body: <p>I'm testing a method using Sweet Alert, to improve the messages issued by the Javascript alert method with the laravel framework.</p>
  
  <p>1 - I downloaded the files sweetalert.css and sweetalert.min.js.</p>
  
  <p>2 - So I connect the files from app.blade.php</p>
  
  <pre><code>&lt;!-- Sweet Alert --&gt;
  &lt;link href="{{ asset('/dist/css/sweetalert.css') }}" rel="stylesheet"&gt;
  &lt;!-- Sweet Alert --&gt;
  &lt;script src="{{ asset('/dist/js/sweetalert.min.js') }}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>3 - I created the delete button using the onclick event of Javascript and the following Sweet Alert function:</p>
  
  <pre><code>{!! Form::open(['method' =&gt; 'DELETE','route' =&gt; ['users.destroy', $user-&gt;id],'style'=&gt;'display:inline']) !!}
  &lt;button onclick="
   swal({
    title: 'Esta seguro de realizar esta Acción?',
    text: 'Si procede este usuario será eliminado!',
    type: 'warning',
    showCancelButton: true,
    confirmButtonColor: '#DD6B55',
    confirmButtonText: 'Eliminar!',
    cancelButtonText: 'Cancelar',
    closeOnConfirm: false,
    closeOnCancel: false
  },
  function(){
    swal('Usuario eliminado!', 'Este usuario fue eliminado de nuestros registros.', 'success');
  });"
    class="btn btn-danger" data-toggle="tooltip" data-placement="top" title="Eliminar usuario"&gt; &lt;i class="material-icons"&gt;delete&lt;/i&gt; 
  &lt;/button&gt;
  {!! Form::close() !!}
  </code></pre>
  
  <p>4 - This is my method for deleting users from UserController:</p>
  
  <pre><code>public function destroy($id)
  {
      User::find($id)-&gt;delete();
      return redirect()-&gt;route('users.index')
                      -&gt;with('success','User deleted successfully');
  }
  </code></pre>
  
  <p>5 - The problem occurs when deleting a user, displays the alert message.</p>
  
  <p><a href="https://i.stack.imgur.com/vTszi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vTszi.png" alt="Message generated by Sweet Alert"></a></p>
  
  <p>But automatically closes and deletes the user without allowing to take the confirmation actions, whether or not to delete the user, method defined in Sweet Alert.</p>
  
  <p>Someone who can give a help to correct this problem or recommend a better method, since I am using Laravel as Framework.</p>