I have tried to upload the image using Postman and the image is stored in the preferred directory and the full path is stored in database but i am getting the error response
"message": "Call to a member function extension() on string",
here is my code
public function store(AvatarUploadRequest $request, UserService $userService) {
$user = $request->user();
try {
$file = $request->file('avatar');
$file = url("/avatars") . "/" . $user->uuid . ".jpg";
$destinationPath = "avatars";
$user->avatar = $request->file('avatar')->move($destinationPath, $file)
->getClientOriginalExtension();
$user->avatar = $file;
$user->save();
  $userService->updateAvatar($user, $file);
} 
catch (\Exception $e) {
  return jsonApiResponse([
    'avatar' => $e->getMessage(),
  ], 422);
}
return jsonApiResponseWithData($user, 201);
}
 
     
     
     
     
     
    