@php $total = (float) ($total ?? 0); $balance = (float) ($balance ?? 0); $paid = max(0, $total - $balance); $studentName = trim(($invoice->student->first_name ?? '') . ' ' . ($invoice->student->last_name ?? '')); $dueDate = $invoice->dueDate ? \Carbon\Carbon::parse($invoice->dueDate)->format('M j, Y') : null; $rows = [ ['label' => 'Invoice #', 'value' => $invoice->invoiceNumber ?? '-'], ]; if ($studentName !== '') $rows[] = ['label' => 'Student', 'value' => $studentName]; $rows[] = ['label' => 'Amount', 'value' => 'CA$' . number_format($total, 2)]; $rows[] = ['label' => 'Paid', 'value' => 'CA$' . number_format($paid, 2)]; $rows[] = ['label' => 'Balance Due', 'value' => 'CA$' . number_format($balance, 2)]; if ($dueDate) $rows[] = ['label' => 'Due Date', 'value' => $dueDate]; @endphp Hello{{ !empty($parent['name']) ? ' ' . $parent['name'] : '' }}, @include('emails.plain.generic', [ 'heading' => 'Invoice ' . ($invoice->invoiceNumber ?? ''), 'intro' => 'Please find attached invoice ' . ($invoice->invoiceNumber ?? '') . ($studentName !== '' ? ' for ' . $studentName : '') . '.', 'rows' => $rows, 'note' => 'Thank you for choosing ' . config('company.name') . '.', ])