filters = $filters; } public function query() { $query = Shipment::query() ->with(['fromCountry', 'toCountry', 'carrierMappings', 'items']) ->orderByDesc('created_at'); if (!empty($this->filters['status'])) { $query->where('status', $this->filters['status']); } if (!empty($this->filters['type'])) { $query->where('type', $this->filters['type']); } if (!empty($this->filters['direction'])) { $query->where('direction', $this->filters['direction']); } if (!empty($this->filters['from_date'])) { $query->where('created_at', '>=', $this->filters['from_date']); } if (!empty($this->filters['to_date'])) { $query->where('created_at', '<=', $this->filters['to_date']); } return $query; } public function headings(): array { return [ 'AWB No.', 'جهت', 'نوع', 'وضعیت', 'کشور مبدا', 'کشور مقصد', 'وزن واقعی (kg)', 'وزن حجمی (kg)', 'وزن قابل پرداخت (kg)', 'قیمت حمل (درهم)', 'خدمات اضافی (درهم)', 'هزینه بسته‌بندی (ریال)', 'دریافت داخلی (ریال)', 'تحویل داخلی (ریال)', 'هزینه انبار (ریال)', 'تخفیف (ریال)', 'هزینه کل (ریال)', 'فرستنده', 'تلفن فرستنده', 'گیرنده', 'تلفن گیرنده', 'تاریخ ایجاد', ]; } public function map($shipment): array { return [ $shipment->awb_no, $shipment->direction->label(), $shipment->type->label(), $shipment->status->label(), $shipment->fromCountry->name ?? '-', $shipment->toCountry->name ?? '-', $shipment->weight ?? 0, $shipment->volumetric_weight ?? 0, $shipment->chargeable_weight ?? 0, $shipment->shipping_price ?? 0, $shipment->extra_service ?? 0, $shipment->packing_cost ?? 0, $shipment->domestic_pickup ?? 0, $shipment->domestic_delivery ?? 0, $shipment->warehousing_cost ?? 0, $shipment->discount ?? 0, $shipment->total_fee ?? 0, $shipment->sender_name ?? '-', $shipment->sender_phone ?? '-', $shipment->receiver_name ?? '-', $shipment->receiver_phone ?? '-', $shipment->created_at?->format('Y/m/d H:i'), ]; } public function styles(Worksheet $sheet) { return [ 1 => ['font' => ['bold' => true, 'size' => 12]], ]; } }