-
- private function handleSingleUserUpdate(UserAvatars $userAvatar): int
- {
- $id = $this->option('id');
- $email = $this->option('email');
- if (!$id && !$email) {
- $this->error('Either a --id=<number> or --email=<email> option must be provided.');
- $this->error('Run with `--help` to more options');
-
- return self::FAILURE;
- }
-
- $field = $id ? 'id' : 'email';
- $value = $id ?: $email;
-
- $user = User::query()
- ->where($field, '=', $value)
- ->first();
-
- if (!$user) {
- $this->error("A user where {$field}={$value} could not be found.");
-
- return self::FAILURE;
- }
-
- $this->info("This will refresh the avatar for user: \n- ID: {$user->id}\n- Name: {$user->name}\n- Email: {$user->email}\n");
- $confirm = $this->confirm('Are you sure you want to proceed?');
- if ($confirm) {
- if ($this->fetchAvatar($userAvatar, $user)) {
- $this->info('User avatar has been updated.');
- return self::SUCCESS;
- }
-
- $this->info('Could not update avatar please review logs.');
- }
-
- return self::FAILURE;
- }
-