Support the ongoing development of Laravel.io →
Eloquent Views Forms
Last updated 1 year ago.
0

In your restfull controllers you have a default method which handles deletion. the method is called destroy.
Your problem is in route naming. More info here.
You defined the route well, but did not assign a route name. Do this instead

Route::delete('delete/{id}',array('uses' => 'PreguntaController@destroy', 'as' => 'My.route'));

Now you can reference the route in your view

{{ Form::open(['route' => ['My.route', $value->id], 'method' => 'delete']) }}
<button type="submit">Delete</button>
{{ Form::close() }}

If you defined your resource controller in routes, then there is already a named route which points to the destroy method.

Route::resource('Pregunta', 'PreguntaController');
{{ Form::open(['route' => ['Pregunta.destroy', $value->id], 'method' => 'delete']) }}
{{ Form::submit('Delete') }}
{{ Form::close() }}
Last updated 1 year ago.
0

Hey @Fritzberg, I'm just wondering how 'good' an approach it is to have forms for the butttons like you are doing. I quite like the approach and it looks good and clear in the code :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Cristiian cristiian Joined 6 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.