使用laravel 5.4无法删除记录

时间:2017-07-04 14:58:22

标签: php laravel-5.4 query-builder

我有按钮删除

{!! Form::open([
                    'route' => ['articles.destroy', $art->id],
                    'method' => 'DELETE',
                    'class' => ''
                ]) !!}
                    <button type="button" class="delete btn btn-danger glyphicon glyphicon-trash"> &nbsp;DELETE</button>
                {!! Form::close() !!}

我的路线:

Route::delete('/articles/delete/{id}', [
'as' => 'articles.destroy',
'uses' => 'ArticlesController@destroy'

]);

我的控制器:

public function destroy($id)
{
    $article = Article::find($id);
    $article->delete();
}

我的问题是当我点击删除按钮时它没有做任何事情

1 个答案:

答案 0 :(得分:0)

必须提交表格以致电路线。为此,您应将type="button"更改为type="submit"