subject; if ($subject instanceof Order) { return $subject->customer?->name ?? 'Order'; } if ($subject instanceof Host) { return $subject->name; } return class_basename($run->subject_type); } public function render() { $runs = ProvisioningRun::query()->latest('id')->limit(30)->get(); $active = $runs->first(fn (ProvisioningRun $r) => in_array( $r->status, ['pending', 'running', 'waiting'], true )) ?? $runs->first(); return view('livewire.admin.provisioning', [ 'hasActive' => $active !== null && in_array($active->status, ['pending', 'running', 'waiting'], true), 'rows' => $runs->map(fn (ProvisioningRun $r) => [ 'customer' => $this->subjectLabel($r), 'pipeline' => $r->pipeline, 'step' => $r->status === 'completed' ? '—' : $this->currentStepLabel($r), 'n' => ($r->current_step + 1).'/'.count(config('provisioning.pipelines.'.$r->pipeline, [])), 'attempt' => $r->attempt, 'state' => $this->runState($r), ])->all(), 'steps' => $active ? $this->buildRunSteps($active) : [], 'activeLabel' => $active ? $this->subjectLabel($active).' · '.$active->pipeline : '—', ]); } }