title: Laravel 4 restful delete a record with a resource controller
body: <p>I am new to Laravel framework but I really like it.
  My biggest problem is I have been searching on how I can delete a single record using resource controller.</p>
  
  <p>Controller method:</p>
  
  <pre><code>public function destroy($id) {
      $department = Department::find($id);
      $department-&gt;delete();
  }
  </code></pre>
  
  <p>Delete link I have tried:</p>
  
  <pre><code>&lt;a class="btn btn-xs btn-danger" data-method="delete" href="{{ URL::to('department/' . $department-&gt;id) }}"&gt;&lt;i class="icon-remove"&gt;&lt;/i&gt;&lt;/a&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function(){
      $('[data-method]').append(function(){
          return "\n" +
          "form action='" + $(this).attr('href') + "' method='post' style='display: none;'&gt;\n" + 
          "&lt;input type='hidden' name='_method' value='"+$(this).attr('data-method')+"'&gt;\n" +
          "&lt;/form&gt;\n"
      })
      .removeAttr('href')
      .attr('style', 'cursor: pointer;')
      .attr('onclick', '$(this).find("form").submit();');
  });
  </code></pre>
  
  <p></p>
  
  <p>Now when I click on the delete link, it doesn't work.
  Any idea on what am I doing wrong, I have been searching for so long.</p>