with(['lines', 'user', 'party'])->orderByDesc('id')->limit(300)->get() as $order) { $url = OrderResource::getUrl('view', ['record' => $order]); $zustand = [$order->status]; $chips = [ match ($order->status) { 'bezahlt' => ['label' => 'Bezahlt', 'ton' => 'gut'], 'erstattet' => ['label' => 'Erstattet', 'ton' => 'leise'], 'fehlgeschlagen' => ['label' => 'Fehlgeschlagen', 'ton' => 'leise'], default => ['label' => $order->payment_method === 'rechnung' ? 'Offen: wartet auf Zahlungseingang' : 'Offen', 'ton' => 'offen'], }, ['label' => match ($order->payment_method) { 'rechnung' => 'Rechnung', 'stripe' => 'Stripe', default => 'Testzahlung' }, 'ton' => 'neutral'], ['label' => Money::format($order->payable()), 'ton' => 'neutral'], ]; if ($order->discount_cents > 0) { $chips[] = ['label' => 'Rabatt '.($order->discount_snapshot['code'] ?? ''), 'ton' => 'neutral']; } if ($order->withdrawal_requested_at !== null) { $chips[] = ['label' => 'Widerruf erklärt', 'ton' => 'offen']; $zustand[] = 'widerruf'; } if ($order->payment_method === 'rechnung' && $order->status === 'offen') { $zustand[] = 'rechnung_offen'; } $rows[] = [ 'schluessel' => 'o'.$order->id, 'titel' => 'Bestellung '.$order->id, 'meta' => ($order->party?->display_name ?? '–').' · bestellt von '.($order->user?->name ?? '–'), 'text' => $order->lines->pluck('offer_name')->implode('; '), 'suchtext' => (string) ($order->user?->email ?? ''), 'symbol' => 'etikett', 'url' => $url, 'chips' => $chips, 'zustand' => $zustand, 'aktionen' => [['label' => 'Öffnen', 'href' => $url]], ]; } return $rows; } protected function zustandOptionen(): array { return [ 'alle' => 'Jeder Zustand', 'rechnung_offen' => 'Rechnung: wartet auf Zahlungseingang', 'widerruf' => 'Widerruf erklärt', 'offen' => 'Offen', 'bezahlt' => 'Bezahlt', 'erstattet' => 'Erstattet', ]; } protected function suchPlatzhalter(): string { return 'Nummer, Name, E-Mail oder Angebot'; } protected function einheit(): array { return ['Bestellung', 'Bestellungen']; } protected function leer(): array { return ['titel' => 'Noch keine Bestellungen', 'text' => 'Sobald im Shop bestellt wird, erscheinen die Bestellungen hier.']; } }