jeudi 3 décembre 2015

how to delete record using eloquent in laravel 5.1

I have done create, edit and update now I am trying to delete record using id but it's throwing exception MethodNotAllowedHttpException in RouteCollection.php line 219:, what I am doing wrong.

Route:

Route::delete('authors/{id}/delete', array('as' => 'delete_route', 'uses' => 'authors_controller@delete'));

Controller:

public function delete($id){
$author = author::find($id);
$author->delete();
return redirect('authors');
}

Form:

    {!! Form::open($author, ['method'=> 'delete', 'url' => 'authors/' . $author->id . '/delete']) !!}

    {!! Form::close() !!}     



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire