Laravel5.1 two ways to delete an operation form
1. Form operations
Laravel is required to install laravelcollective
"require": {"php": ">=5.5.9","laravel/framework": "5.1.*","laravelcollective/html": "5.1.*"},
You can use {!! Form: open ()!!} Tag
As follows:
{!! Form: open (array ('URL' => route ('admin. shop_category_tag.destroy ', $ shop_category_tag-> id), 'method' => 'Delete '))!!} {!! Form: submit ('delete', array ('class' => 'btn btn-info btn-danger '))!!} {!! Form: close ()!!}
If not installed
Use the default HTML form to submit and delete the file. for example:
The controller method can be written as follows:
Public function destroy ($ id) {$ shop_category_tag = Shop_category_tag: find ($ id); if ($ shop_category_tag-> delete () {return Redirect: back () -> with ('message', 'deleted successfully! ');} Else {return Redirect: back ()-> withInput ()-> with ('errors', 'deletion failed! ');}}
Route:
Route::resource('shop_category_tag','ShopCategoryTagController');
2. new controller methodDelete ()
The controller content is the same as the preceding one. However, you must note that you need to add a delete () method for the route, which will increase the complexity of the route. The second method is not recommended here.
Address: http://note.mango.im/article/8