option('id'); $email = $this->option('email'); if (!$id && !$email) { throw new Exception("Either a --id= or --email= option must be provided.\nRun this command with `--help` to show more options."); } $field = $id ? 'id' : 'email'; $value = $id ?: $email; $user = User::query() ->where($field, '=', $value) ->first(); if (!$user) { throw new Exception("A user where {$field}={$value} could not be found."); } return $user; } }