用laravel框架怎么實現(xiàn)刪除
1 回答

慕絲7291255
TA貢獻1859條經(jīng)驗 獲得超6個贊
刪除鏈接
編輯在app/views/articles/index.blade.php文件,在列表視圖每個文章后面,添加刪除菜單:
MENU:
{{ Form::open(array('method' => 'DELETE', 'route' => array('articles.destroy', $article->id))) }}
{{ Form::submit('Delete') }}
{{ Form::close() }}
執(zhí)行刪除
修改 ArticlesController 控制器 destroy 動作的代碼:
public function destroy($id)
{
Article::destroy($id);
return Redirect::route('articles.index');
}
注意,刪除后,直接跳轉到列表頁面。
- 1 回答
- 0 關注
- 742 瀏覽
添加回答
舉報
0/150
提交
取消