当我尝试编辑没有图片的用户帖子时,我收到此错误“调用 null 时的成员函数 store()”,但是当我尝试编辑带图片的用户帖子时,我没有收到错误。
这是我的html代码
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="ur-thumb">
<label for="picture">
<input id="picture" type="file" name="cv_picture" style="display: none" onchange="readUrl(this)">
<img id="myImage" src="{{Storage::url($usersCv->picture)}}" class="img-responsive pointer" alt="" />
</label>
</div>
@error('cv_picture')
<strong style="color: red">{{$message}}</strong>
@enderror
</div>
这是我的控制器
public function updateUserCv(CvRequest $request, $id)
{
$userId = Auth::id();
Cv::where('id', $id)
->where('user_id', $userId)
->update([
'name' => $request['name'],
'surname' => $request['surname'],
'father_name' => $request['fatherName'],
'gender' => $request['gender'],
'year' => $request['year'],
'category_id' => $request['catId'],
'position_name' => $request['position'],
'type_id' => $request['typId'],
'education' => $request['education'],
'education_description' => $request['about_education'],
'experience_id' => $request['expId'],
'experience_descriptions' => $request['about_work'],
'city_id' => $request['cityId'],
'salary' => $request['salary'],
'skills' => $request['skills'],
'other_information' => $request['other'],
'mobile' => $request['mobile'],
'email' => $request['email'],
'picture' => ($request->file('cv_picture')->store('public/profile')),
]);
toastr()->success('Success.', 'ok!');
return redirect('user-cv/'.$id);
}