0
I use the form below to send the id of the row to be deleted in the table:
<form method="DELETE" action="{{ URL::to('receitas/delete') }}" >
<input type="hidden" name="id" value="{{ $receita->id }}" >
<button type="submit" class="button-deletar" ></button>
</form>
My controller has the following Function:
public function getDestroy($id){
// delete
$receita = Receita::find($id);
$receita->delete();
// SALVANDO LOG
$logger = Helper::salvaLog("receitas",$id,"exclusao");
// redirect
Session::flash('message', 'Receita excluída com sucesso!');
return Redirect::to('receitas');
}
The Routes are like this:
Route::controller('receitas', 'ReceitaController');
Route::delete('receitas/{id}', ReceitaController@getDestroy );
Because returns 404 page not found ( local/receitas/7
)?
Dear gmsantos, I made the changes as you suggested and I still could not delete from the database, but the return is no longer page not found but the url: local/recipes? _method=Delete&id=7
– CleitonHatsu
@Cleitonhatsu vc used the form of the Laravel or the second option? try to change the method of the form to post, as the answer edited.
– gmsantos