0
さて、ここでは私のコントローラでstoreメソッドです:
public function store(EmployeeRequest $request)
{
if($request->hasFile('photo')){
$path = $request->photo->store('employeeimages');
// This should have changed the element in the $request['photo'] index:
$request->photo = $path;
dd($request->all());
}
Employee::create($request->all());
return redirect('dashboard');
}
私は$request->photo
は私たちに、配列の$request['photo']
要素へのアクセスを提供しますと思ったが、私は試してみました$request->photo = $path;
で更新しますが、私が死んで$request->all()
をダンプすると、$request['photo']
は更新されず、UploadedFile
クラスのインスタンスである以前の値への参照が保持されます。 $ request配列の要素を変更するにはどうすればよいですか?
あなたは '$ request-> merge($ array)'を使うこともできます。 –