@php $isModel = $invoice instanceof \App\Models\Invoice; $modelItems = $isModel && $invoice->relationLoaded('items') ? $invoice->items : collect(); if ($isModel) { $business = $invoice->business ?? $currentBusiness; $customer = $invoice->customer; $invoiceDisplay = [ 'number' => $invoice->invoice_number ?: 'INV-0000', 'status' => $invoice->status_label ?: 'Draft', 'statusValue' => $invoice->status_value ?: 'draft', 'issueDate' => $invoice->issue_date?->format('M d, Y') ?? now()->format('M d, Y'), 'dueDate' => $invoice->due_date?->format('M d, Y') ?? now()->addDays(7)->format('M d, Y'), 'customer' => $customer?->name ?? 'Customer Name', 'email' => $customer?->email ?? 'customer@example.com', 'phone' => $customer?->phone ?? 'Phone not added', 'business' => $business?->name ?? 'Booklio Business', 'businessEmail' => $business?->email ?? 'billing@booklio.test', 'businessPhone' => $business?->phone ?? '(555) 900-1200', 'businessAddress' => $business?->address ?? 'Business address', 'currency' => $invoice->currency ?: ($business?->currency ?? 'USD'), 'subtotal' => (float) $invoice->subtotal, 'tax' => (float) $invoice->tax_total, 'discount' => (float) $invoice->discount_total, 'total' => (float) $invoice->total, 'paid' => (float) $invoice->paid_total, 'balance' => (float) $invoice->balance_due, 'notes' => $invoice->notes ?: $invoice->footer_note ?: 'Thank you for booking with us.', ]; $items = $items ?? $modelItems->map(fn ($item) => [ 'name' => $item->service?->name ?? $item->description, 'description' => $item->description, 'qty' => $item->quantity, 'price' => (float) $item->unit_price, 'total' => (float) $item->line_total, ])->all(); } else { $invoiceDisplay = array_merge([ 'number' => 'INV-0000', 'status' => 'Draft', 'statusValue' => 'draft', 'issueDate' => now()->format('M d, Y'), 'dueDate' => now()->addDays(7)->format('M d, Y'), 'customer' => 'Customer Name', 'email' => 'customer@example.com', 'phone' => 'Phone not added', 'business' => 'Booklio Business', 'businessEmail' => 'billing@booklio.test', 'businessPhone' => '(555) 900-1200', 'businessAddress' => 'Business address', 'currency' => 'USD', 'subtotal' => 0, 'tax' => 0, 'discount' => 0, 'total' => 0, 'paid' => 0, 'balance' => 0, 'notes' => 'Thank you for booking with us.', ], $invoice ?? []); } $items = $items ?? []; if (count($items) === 0) { $items = [ ['name' => 'Service appointment', 'description' => 'Invoice item preview', 'qty' => 1, 'price' => 0, 'total' => 0], ]; } $money = fn ($amount) => $invoiceDisplay['currency'].' '.number_format((float) $amount, 2); $statusVariants = [ 'draft' => 'muted', 'unpaid' => 'warning', 'partial' => 'purple', 'paid' => 'success', 'overdue' => 'danger', 'cancelled' => 'muted', ]; @endphp
{{ $invoiceDisplay['business'] }}
Premium appointment invoice
{{ $invoiceDisplay['businessAddress'] }}
{{ $invoiceDisplay['businessEmail'] }} - {{ $invoiceDisplay['businessPhone'] }}
INVOICE
{{ $invoiceDisplay['number'] }}
Bill To
{{ $invoiceDisplay['customer'] }}
{{ $invoiceDisplay['email'] }}
{{ $invoiceDisplay['phone'] }}
Issue Date
{{ $invoiceDisplay['issueDate'] }}
Due Date
{{ $invoiceDisplay['dueDate'] }}
Notes
{{ $invoiceDisplay['notes'] }}