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() }}
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 :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community