private function removeOldProfileImage() { if (Auth::user()->avatar_url != '' && Auth::user()->account_type == 'normal') { $fm = new FileManager(); $fm->removeFile(Auth::user()->avatar_url); } }
/** * Display the avatar of the user * * @return \Illuminate\Contracts\Routing\UrlGenerator|mixed|string */ public function avatar() { if ($this->avatar_url != null && $this->avatar_url != '') { $fm = new FileManager(); return $fm->uriToUrl($this->avatar_url); } return url('admin_lte/img/anonymous.jpg'); }
/** * Handle the save user profile image * * @param Request $request * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response */ public function postSaveUserAvatar(Request $request) { $user = new User(); $user->handleUserProfilePicUpdate($request); $fm = new FileManager(); $file = $fm->uploadImageFileFromBase64String($request->input('avatar'), 'fw-labs-db/uploads/profile_pic/', null, 's3'); $user = Auth::user(); $user->avatar_url = $file->file_path; $user->save(); return response(['data' => ['image_url' => $fm->uriToUrl($file->file_path)]], 200); }