2
控制器缺少參數2爲App HTTP 控制器 UserController中::店()
public function store(Request $request,$id)
{
$new = Car::find($id);
$new->status = $request ->input('field');
$new->save();
redirect('home');
}
查看
@foreach($users as $user)
@foreach($user->cars as $users)
{!! Form::open(['route' => 'user.store', 'method'=>'post','id'=> '$users->id']) !!}
<th scope="row">1</th>
<td>{!! Form::label($cars->name)!!}<td>
<td>{!! Form::label($cars->age)!!}<td>
<td>{{Form::select($cars->status, ['R' => 'Requested', 'C' => 'Coming', ['name' => 'field']])}} // name is worong but I dont know the alternative
<td>{!! Form::submit('Update Profile', ['class' => 'btn btn-primary']) !!}</td>
{{ Form::close() }}
路線
Route::Resource('user', 'UserController');
問題
嘗試將所選值從status
保存到汽車模型中。但我得到一個有關參數的錯誤。有人能告訴我我的錯誤在哪裏嗎?我是Laravel的新手。
謝謝你的幫助。但它仍然給我'應用程序\ Http \ Controllers \ UserController :: store()缺少參數2'我認爲錯誤在我的控制器@Alexey Mezenin – leo0019
'$ new-> status = $ request - > input('字段');'我對這行代碼沒有信心 – leo0019
它返回正確的用戶ID(這是汽車ID) – leo0019