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

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