我有一个真正的问题得到一个按钮扫描和清除整个列使用一个有说服力的模型。我有两列在我的SQLite数据库,"状态"answers"总数"…我希望各州保持自己的顺序,但我希望在用户选择按钮时清除总数。'totals'的字符类型是BigInt…在用户选择按钮后,我希望他们重定向到主页(清除值,以便他们可以重新开始)。
这是我的路线:
Route::resource('states', 'StateController');
Route::get('/', 'StateController@index');
Route::post('create', 'StateController@store');
Route::post('states.update', 'StateController@update');
这是我的控制器:
public function update()
{
Distributors::update(['total' => null]);
return View::make('states');
}
这是我的表格:
{{ Form::open(['route' => 'states.update']) }}
{{ Form::submit('Destroy and Start Anew') }}
{{ Form::close() }}
我得到的错误是:
MethodNotAllowedHttpException
我的路线有一个简单的问题吗?我想不明白。
您没有在表单上指定method
属性,因此它将自动执行GET请求。您的state.update
路由只设置为接受POST请求。
把你的表单改成:
{{ Form::open(['route' => 'states.update', 'method' => 'post']) }}
请删除
路线:资源("州"、"StateController");