query->latest('id'); } public function moneyColumns(): array { return ['F', 'G', 'H']; } public function headings(): array { return [ 'Mã đơn hàng', 'Ngày đặt', 'Khách hàng', 'Email', 'Dịch vụ', 'Tạm tính', 'Giảm giá', 'Tổng tiền', 'Trạng thái', 'Phương thức thanh toán', 'Hoá đơn', 'Ghi chú', 'Ngày tạo', ]; } /** * @param Order $order */ public function map($order): array { return [ $order->order_num, $this->formatDate($order->date), $order->customer?->fullname, $order->customer?->email, $this->describeServices($order), (int) $order->sub_total, (int) $order->discount_amount, (int) $order->total, OrderStatus::tryFrom((int) $order->status)?->label() ?? $order->status, $order->payment?->name ?? $this->paymentMethodLabel($order->payment_method), $order->invoices->pluck('invoice_number')->implode(', '), $order->note, $this->formatDate($order->created_at, 'd/m/Y H:i'), ]; } }