Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Call to a member function store() on string"
添加if
条件后,出现错误消息,并且数据库文件中的数据未更新。
$this->authorize('update', $user->profile);
$data= request()->validate([
'title' =>'required',
'description'=>'required',
'url'=>'url',
'image'=>'',
]);
if (request('image'))
{
$imagePath=request('image')->store('profile', 'public');
$image=Image::make(public_path("storage/{$imagePath}"))->fit(1000, 1000);
$image->save();
}
auth()->user()->profile->update(array_merge($data,
['image' => $imagePath]
));
return redirect("/profile/{$user->id}");
//dd($data);
}
此行出现错误:
$imagePath=request('image')->store('profile', 'public');