title('Lookup Money'); while (true) { $io->info('Checking pending'); if ($this->hasPendingMoney()) { $io->success('Running money get UF'); $io->note($this->runGetUF()); } } } protected function hasPendingMoney(): bool { $query = "SELECT 1 FROM pago WHERE uf IS NULL AND fecha BETWEEN 0 AND DATE_ADD(CURDATE(), INTERVAL 9 DAY)"; $statement = $this->connection->connect()->query($query); return $statement->rowCount() > 0; } protected function runGetUF(): string { $command = "/code/bin/console money:uf:get"; $result = shell_exec($command); if (!$result or $result === null) { throw new \Exception(); } return $result; } }