data = $data; } public function collection() { $collection = collect(); // Add summary row first 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'], ]); // Add empty row separator $collection->push(['', '', '', '']); } // Add individual produk data if (isset($this->data['produk'])) { foreach ($this->data['produk'] as $item) { $collection->push([ $item['nama_produk'], $item['jumlah_item_terjual'], $item['berat_terjual'], $item['pendapatan'], ]); } } return $collection; } public function headings(): array { return [ 'Nama Produk', 'Jumlah Item Terjual', 'Berat Terjual', 'Pendapatan' ]; } public function title(): string { $filterInfo = $this->data['filter'] ?? []; $tanggal = $filterInfo['tanggal'] ?? 'Unknown'; return "Detail Produk {$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; } }