【发布时间】:2018-11-22 07:29:21
【问题描述】:
这是我的路线:
Route::get('admin/edit-news/{id}', 'AdminNewsController@edit');
我的 Controller@update 方法:
public function update(Request $request, $id)
{
$news = News::find($id);
$news->title = $request->input('title');
$news->content = $request->input('content');
$news->save();
return redirect ('/admin');
}
以及我对自定义表单的看法:
{{ Form::open(['action' => ['AdminNewsController@update', $news->id], 'method' => 'POST']) }}
{{ Form::bsText('title', $news->title) }}
{{ Form::bsTextArea('content', $news->content) }}
{{ Form::hidden('_method', 'PUT') }}
{{ Form::bsSubmit('Confirm', ['class' => 'btn btn-primary center-block']) }}
{!! Form::close() !!}
我得到的错误是
“Action App\Http\Controllers\AdminNewsController@update 未定义。(查看:D:\xampp\htdocs\laravelhotel\resources\views\admin\news\edit_news.blade.php)”
我不知道为什么,因为我放的动作是更新功能,并且我在 FormServiceProvider 中注册了所有组件。
【问题讨论】:
-
POST 路由是什么样的?
-
我只是注意到我根本忘了放它!这么愚蠢的错误。谢谢!
-
现在是我的发布路线 Route::post('admin/edit-news/submit', 'AdminNewsController@update');给出这个错误 MethodNotAllowedHttpException No message
标签: forms laravel-5.7 laravelcollective