each(function (Tenant $tenant): void { $observations = IntakeObservation::query()->with(['channel', 'booking']) ->where('occurred_at', '>=', now()->subDays((int) $this->option('days')))->orderBy('occurred_at')->get(); $this->line("{$tenant->name}: ".$observations->count().' Einträge'); $this->table(['Wann', 'Portal', 'Quelle', 'Zeitraum', 'Ergebnis', 'Ausgeführt', 'Vorgang', 'Begründung'], $observations->map(fn (IntakeObservation $observation): array => [ $observation->occurred_at->format('d.m. H:i'), $observation->channel?->name, $observation->sourceLabel(), $observation->starts_on ? $observation->starts_on->format('d.m.').'–'.$observation->ends_on?->format('d.m.Y') : '–', $observation->outcome->getLabel(), $observation->applied ? 'ja' : 'nur protokolliert', $observation->booking?->reference ?? '–', implode(' ', (array) $observation->reasons), ])->all()); $wouldCreate = $observations->filter(fn (IntakeObservation $observation): bool => ! $observation->applied && in_array($observation->outcome, [IntakeOutcome::Create, IntakeOutcome::Inquiry], true))->count(); $this->info("Wären entstanden (Beobachten): {$wouldCreate}"); }); return self::SUCCESS; } }