我想知道是否有人可以查看此代码并告诉我它为什么不起作用。当我按下提交按钮时,它将不会提交。
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
我将其提交给PostController的destory方法,其中路线被定义为' posts'。
路线档案
Route::group(['prefix' => 'admin'], function() {
Route::resource('posts', 'PostController');
});
答案 0 :(得分:-1)
更改
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
要
{!! Form::open([
'method' => 'DELETE',
'route' => ['admin.posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
在路线中加上你的前缀。希望它会有所帮助