无法使用 laravel 5.4 删除记录
Cannot delete record using laravel 5.4
我有删除按钮
{!! Form::open([
'route' => ['articles.destroy', $art->id],
'method' => 'DELETE',
'class' => ''
]) !!}
<button type="button" class="delete btn btn-danger glyphicon glyphicon-trash"> 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();
}
我的问题是当我点击删除按钮时没有任何反应
必须提交表格才能调用路由。为此,您应该将 type="button"
更改为 type="submit"
。
我有删除按钮
{!! Form::open([
'route' => ['articles.destroy', $art->id],
'method' => 'DELETE',
'class' => ''
]) !!}
<button type="button" class="delete btn btn-danger glyphicon glyphicon-trash"> 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();
}
我的问题是当我点击删除按钮时没有任何反应
必须提交表格才能调用路由。为此,您应该将 type="button"
更改为 type="submit"
。