我在刀片中使用了@method('PUT')
,但是它仍然说PUT
方法不受支持,有人知道这是什么问题吗?
我的路线是: routes
这是我的工作坊控制器编辑参数和存储。
public function edit(Workshops $workshops)
{
$result = compact('workshops');
Json::dump($result);
return view('admin.workshops.edit', $result);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Workshops $workshops
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Workshops $workshops)
{
$this->validate($request,[
'name' => 'required|unique:workshops' . $workshops->id,
'datum' => 'required'. $workshops->id,
'plaatsen' => 'required' . $workshops->id,
'price' => 'required'
]);
$workshops->name = $request->name;
$workshops->datum = $request->datum;
$workshops->plaatsen = $request->plaatsen;
$workshops->price = $request->price;
$workshops->save();
session()->flash('success', 'The workshop has been updated');
return redirect('admin/workshops');
}
答案 0 :(得分:2)
在您的路由文件中,您需要使用Route :: put()作为要使用的路由。 https://laravel.com/docs/7.x/routing#basic-routing
答案 1 :(得分:0)
您必须像这样使用
Route::post('/admin/workshops/{id}', 'ControllerNameController@methodName');
答案 2 :(得分:0)
您需要使用PUT定义路线,如下所示
Route :: put('/ admin / workshops / {id}','ControllerName @ methodName');