/*
Exemples : 
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}"> 
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
*/


(function() {
 
  var laravel = {
    initialize: function() {
      this.methodLinks = $('a[data-method]');
      this.token = $('a[data-token]');
      this.registerEvents();
    },
 
    registerEvents: function() {
      this.methodLinks.on('click', this.handleMethod);
    },
 
    handleMethod: function(e) {
      var link = $(this);
      var httpMethod = link.data('method').toUpperCase();
      var form;
 
      // If the data-method attribute is not PUT or DELETE,
      // then we don't know what to do. Just ignore.
      if ( $.inArray(httpMethod, ['PUT', 'DELETE']) === - 1 ) {
        return;
      }
 
      // Allow user to optionally provide data-confirm="Are you sure?"
      if ( link.data('confirm') ) {
        if ( ! laravel.verifyConfirm(link) ) {
          return false;
        }
      }
 
      form = laravel.createForm(link);
      form.submit();
 
      e.preventDefault();
    },
 
    verifyConfirm: function(link) {
      return confirm(link.data('confirm'));
    },
 
    createForm: function(link) {
      var form = 
      $('<form>', {
        'method': 'POST',
        'action': link.attr('href')
      });
 
      var token = 
      $('<input>', {
        'type': 'hidden',
        'name': '_token',
        'value': link.data('token')
        });
 
      var hiddenInput =
      $('<input>', {
        'name': '_method',
        'type': 'hidden',
        'value': link.data('method')
      });
 
      return form.append(token, hiddenInput)
                 .appendTo('body');
    }
  };
 
  laravel.initialize();
 
})();
@@ -6,17 +6,16 @@
 emples :
- 
 %0A%3Ca href
@@ -76,17 +76,16 @@
 en()%7D%7D%22%3E
- 
 %0A- Or, r
@@ -239,18 +239,17 @@
 ion() %7B%0A
- 
 %0A
+
   var la
@@ -404,26 +404,25 @@
 s();%0A    %7D,%0A
- 
 %0A
+
     register
@@ -500,26 +500,25 @@
 od);%0A    %7D,%0A
- 
 %0A
+
     handleMe
@@ -637,18 +637,17 @@
 r form;%0A
- 
 %0A
+
       //
@@ -785,16 +785,25 @@
 ethod, %5B
+'PATCH', 
 'PUT', '
@@ -844,26 +844,25 @@
 rn;%0A      %7D%0A
- 
 %0A
+
       // All
@@ -1045,18 +1045,17 @@
       %7D%0A
- 
 %0A
+
       fo
@@ -1106,18 +1106,17 @@
 bmit();%0A
- 
 %0A
+
       e.
@@ -1136,26 +1136,25 @@
 t();%0A    %7D,%0A
- 
 %0A
+
     verifyCo
@@ -1228,18 +1228,17 @@
 %0A    %7D,%0A
- 
 %0A
+
     crea
@@ -1278,17 +1278,16 @@
 r form =
- 
 %0A      $
@@ -1363,33 +1363,32 @@
 ref')%0A      %7D);%0A
- 
 %0A      var token
@@ -1389,17 +1389,16 @@
  token =
- 
 %0A      $
@@ -1507,26 +1507,25 @@
         %7D);%0A
- 
 %0A
+
       var hi
@@ -1657,18 +1657,17 @@
     %7D);%0A
- 
 %0A
+
       re
@@ -1750,18 +1750,17 @@
  %7D%0A  %7D;%0A
- 
 %0A
+
   larave
@@ -1775,15 +1775,14 @@
 lize();%0A
- 
 %0A%7D)();

fix approval link