Hi Guys, I'm implementing an avatar feature using the User model with an extra column added: 'avatar'.
I'm following along the Laracast Bulk File Uploads and I have everything working except the code which saves the path of the image to the User->avatar field.
I need a little help persisting the string. This is what I have so far...
in the User model
public function saveAvatar($name)
{
$this->fill(['avatar' => $name]);
}
in the Auth controller...
protected function postAvatar($id, Request $request)
{
$file = $request->file('file');
$name = time() . $file->getClientOriginalName();
$user = User::where('id', $id)->get();
$user->avatar = $name;
$user->save();
}
But I get this error:
FatalErrorException in AuthController.php line 100:
Call to undefined method Illuminate\Database\Eloquent\Collection::save()