repository = app()->make(UserRepositoryInterface::class); $this->avatarRepository = app()->make(AvatarRepositoryInterface::class); $this->policy = new UserPolicy(); } public function execute(): void { authorize('update', $this->policy, ['user' => $this->user]); // if (UserEloquentModel::query()->where('email', $this->user->email)->exists()) { // throw new EmailAlreadyUsedException(); // } $avatar = $this->user->avatar; if ($avatar->isBinaryFile()) { $filename = $this->avatarRepository->storeAvatarFile($avatar, $this->user->name); $this->user->setAvatar($filename); } $this->repository->update($this->user, $this->password); } }