FatalThrowableError(E_ERROR)在字符串上调用成员函数store()

时间:2019-07-15 15:43:53

标签: laravel laravel-5 intervention

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');

0 个答案:

没有答案