lundi 15 juillet 2019

FatalThrowableError (E_ERROR) Call to a member function store() on string

Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Call to a member function store() on string"

After adding if condition, I got error message and data aren't update on db file.

 $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);
}

I got the error for this line( $imagePath=request('image')->store('profile', 'public');)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire