aiJob = $aiJob; } public function handle(AiService $aiService) { $statusResponse = $aiService->status($this->aiJob->job_id); $previewResponse = $aiService->preview($this->aiJob->job_id); $this->aiJob->update([ 'status' => $statusResponse['status'] ?? $this->aiJob->status, 'preview' => $previewResponse ?? $this->aiJob->preview ]); if (($statusResponse['status'] ?? '') === 'running') { self::dispatch($this->aiJob)->delay(now()->addSeconds(30)); } } }