Php 嵌套路由上的表单模型绑定-无法修补-在第219行的RouteCollection上返回MethodNotAllowedException

Php 嵌套路由上的表单模型绑定-无法修补-在第219行的RouteCollection上返回MethodNotAllowedException,php,laravel-5.1,nested-routes,Php,Laravel 5.1,Nested Routes,每当我尝试向我的控制器提交补丁请求时,我就会收到方法NotAllowedException错误。它只发生在我的嵌套路由上,所有其他运行补丁的路由都非常有效 routes.php: Route::resource('customers.aircraft','AircraftController'); 我的表格: Form::model($aircraft, ['method' => 'PATCH', 'class' => 'form-horizontal', 'action' =&g

每当我尝试向我的控制器提交
补丁
请求时,我就会收到
方法NotAllowedException
错误。它只发生在我的嵌套路由上,所有其他运行
补丁的路由都非常有效

routes.php:

Route::resource('customers.aircraft','AircraftController');
我的表格:

Form::model($aircraft, ['method' => 'PATCH', 'class' => 'form-horizontal', 'action' => ['AircraftController@update', $aircraft->id]])
每架飞机都属于一个客户。我的URL如下所示:

example.com/customers/5/aircraft/6/edit
当我收到错误消息时,我在地址栏中看到的是:

example.com/customers/6/aircraft
我已经确定这不是由控制器引起的,因为我的
@update
方法的第一行是
dd($request)但它并没有走那么远。我认为问题在于航线没有获得引导我的请求所需的信息,它显然是使用
飞机id
,并将其用作
客户id
,但我不知道如何或为什么

我试过这个:

Form::model($aircraft, ['method' => 'PATCH', 'class' => 'form-horizontal', 'action' => ['AircraftController@update', [$customer_id, $aircraft->id]]])
认为需要发送
客户id
,但这不起作用。我对
Laravel
非常陌生,所以我确实认为这只是缺乏知识,但是Stackoverflow、Laravel或Laracasts网站到目前为止对我没有任何帮助

尝试使用Put()方法:

对于Route::resource,更新方法url应如下所示:

example.com/aircraft/6

public function update(AircraftRequest $request, $aircraft_id) 
{ 
   $data = $request->all();
   dd($data['registration']); 
   $request['registration'] = strtoupper($request['registration']); 
   $aircraft->findOrFail($aircraft_id)->update($request->all());
   return redirect()->action('AircraftController@show', $aircraft_id); 
 }
因此,尝试在隐藏输入中发送客户id。
让我知道它是否有效

仍能获得相同的结果您能给我看看您的AircraftController@update方法公共功能更新(AircraftRequest$request,Aircraft$Aircraft,$customer_id,$Aircraft_id){dd($request);$request['registration']=strtoupper($request['registration']);$Aircraft->findOrFail($aircraft_id)->更新($request->all());返回重定向()->操作($AircraftController@show“,$aircraft_id);}我刚刚添加了$customer_id用于故障排除,我还尝试了不使用aircraft RequestOK的情况下重试,并告诉我它是否返回数据
example.com/aircraft/6

public function update(AircraftRequest $request, $aircraft_id) 
{ 
   $data = $request->all();
   dd($data['registration']); 
   $request['registration'] = strtoupper($request['registration']); 
   $aircraft->findOrFail($aircraft_id)->update($request->all());
   return redirect()->action('AircraftController@show', $aircraft_id); 
 }