Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Update 08/21/2017 for Laravel 5.x</strong></p> <p>The question asks about Laravel 4, but I include this in case people looking for Laravel 5.x answers end up here. The Form and other helpers <a href="https://stackoverflow.com/questions/35695949/why-are-form-and-html-helpers-deprecated-in-laravel-5-x">aren't available as of 5.x</a>. You still need to specify a method on a form if you are doing something besides GET or POST. This is the current way to accomplish that:</p> <pre><code>&lt;form action="/foo/bar" method="POST"&gt; &lt;input type="hidden" name="_method" value="PUT"&gt; &lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt; &lt;!-- other inputs... --&gt; &lt;/form&gt; </code></pre> <p>You can also use <code>{{ method_field('PUT') }}</code> instead of writing out the hidden <code>_method</code> input.</p> <p>See <a href="https://laravel.com/docs/5.4/routing#form-method-spoofing" rel="nofollow noreferrer">https://laravel.com/docs/5.4/routing#form-method-spoofing</a></p> <p><strong>Original Answer for Laravel 4</strong></p> <p>I think when you click the link, it is probably sending a GET request to that end point. CRUD in Laravel works according to REST. This means it is expecting a DELETE request instead of GET.</p> <p>Here's one possibility from a <a href="http://www.codeforest.net/laravel-4-tutorial-part-2" rel="nofollow noreferrer">tutorial</a> by Boris Strahija.</p> <pre><code> {{ Form::open(array('route' =&gt; array('admin.pages.destroy', $page-&gt;id), 'method' =&gt; 'delete')) }} &lt;button type="submit" class="btn btn-danger btn-mini"&gt;Delete&lt;/button&gt; {{ Form::close() }} </code></pre> <p>This way, you send the request in a form with the DELETE method. The article explains why a traditional link won't work:</p> <blockquote> <blockquote> <p>You may notice that the delete button is inside a form. The reason for this is that the destroy() method from our controller needs a DELETE request, and this can be done in this way. If the button was a simple link, the request would be sent via the GET method, and we wouldn’t call the destroy() method.</p> </blockquote> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload