data = $data; } public function collection() { $collection = collect(); // Add individual nampan data if (isset($this->data['nampan'])) { foreach ($this->data['nampan'] as $item) { $collection->push([ $item['nama_nampan'], $item['jumlah_item_terjual'], $item['berat_terjual'], $item['pendapatan'], ]); } } if (isset($this->data['rekap_harian'])) { $rekap = $this->data['rekap_harian']; $collection->push([ 'REKAP TOTAL', $rekap['total_item_terjual'], $rekap['total_berat_terjual'], $rekap['total_pendapatan'], ]); } return $collection; } public function headings(): array { return [ 'Nama Nampan', 'Jumlah Item Terjual', 'Berat Terjual', 'Pendapatan' ]; } public function title(): string { $filterInfo = $this->data['filter'] ?? []; $tanggal = $filterInfo['tanggal'] ?? 'Unknown'; return "Detail Nampan {$tanggal}"; } public function styles(Worksheet $sheet) { $styles = [ 1 => ['font' => ['bold' => true]], // Header row ]; // Style for recap row if exists if (isset($this->data['rekap_harian'])) { $styles[2] = [ 'font' => ['bold' => true], 'fill' => [ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['argb' => 'FFE2E3E5'], ], ]; } return $styles; } }