I will destroy my user with a HTML link, but it doesn\'t seem to generate the correct link, what am i doing wrong?
public function destroy($id)
{
//Slet
For those looking to create the delete button in Laravel 5:
{!! Form::open(['action' => ['UserController@destroy', $user->id], 'method' => 'delete']) !!}
{!! Form::submit('Delete', ['class'=>'btn btn-danger btn-mini']) !!}
{!! Form::close() !!}
This is similar to Tayler's answer but we use the new blade escape tags ( {!! and !!} ), we use the Form facade to generate the button and we use a more elegant approach to link to the controller.
In Laravel < 5 the Forms & HTML package was pulled in automatically. In Laravel 5 we must add this package to composer.json:
...
"required": {
...
"laravelcollective/html": "^5.1"
}
...
Now add the Service Provider and Alias in config/app.php:
...
'providers' => [
...
Collective\Html\HtmlServiceProvider::class,
],
'aliases' => [
...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
],
The above will output
If you are using a different form builder just make sure it generates something similar to the above.