data = $data; } public function collection() { return $this->data; } public function startCell(): string { return 'A7'; } public function headings(): array { return [ 'ID', 'NAMA KUCING (♂/♀)', 'PARENT (SIRE x DAM)', 'REGISTRY', 'KODE EMS', 'NO. PEDIGREE', 'NO. MICROCHIP', 'TGL KAWIN', 'ESTIMASI LAHIR (EDD)', 'STATUS' ]; } /** * @var \App\Models\Matting $item */ public function map($item): array { // Menggunakan Accessor edd dari Model Matting $eddDate = $item->edd ? $item->edd->format('d/m/Y') : '-'; $tglKawin = $item->tgl_kawin_awal ? $item->tgl_kawin_awal->format('d/m/Y') : '-'; // Kita buat mapping yang mencakup data Sire & Dam dalam baris yang informatif return [ $item->id, ($item->sire?->nama_kucing ?? 'N/A') . ' & ' . ($item->dam?->nama_kucing ?? 'N/A'), ($item->sire?->nama_kucing ?? '-') . ' x ' . ($item->dam?->nama_kucing ?? '-'), ($item->dam?->pedigree ?? '-'), 'S: ' . ($item->ems_bapak ?? '-') . ' / D: ' . ($item->ems_ibu ?? '-'), 'S: ' . ($item->no_pedigree_bapak ?? 'Non-pedigree') . ' / D: ' . ($item->no_pedigree_ibu ?? 'Non-pedigree'), 'S: ' . ($item->no_microchip_bapak ?? '-') . ' / D: ' . ($item->no_microchip_ibu ?? '-'), $tglKawin, $eddDate, strtoupper($item->status ?? 'PROSES') ]; } public function registerEvents(): array { return [ AfterSheet::class => function(AfterSheet $event) { $sheet = $event->sheet; $sheet->setCellValue('A1', 'ILY CATTERY - LAPORAN PEMBIAKAN'); $sheet->setCellValue('A2', 'Dicetak Oleh: ' . Auth::user()->name); $sheet->setCellValue('A3', 'Tanggal Cetak: ' . now()->translatedFormat('d F Y H:i')); $sheet->setCellValue('A4', 'Total Data: ' . $this->data->count() . ' Records'); $sheet->setCellValue('A5', 'Sektor: PARENTAL INTELLIGENCE UNIT'); $sheet->getStyle('A1')->getFont()->setSize(16)->setBold(true); $sheet->getStyle('A2:A5')->getFont()->setBold(true); // Memberikan border ke seluruh tabel data $lastRow = $this->data->count() + 7; $sheet->getStyle('A7:J' . $lastRow)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN); }, ]; } public function styles(Worksheet $sheet) { return [ 7 => [ 'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']], 'fill' => ['fillType' => 'solid', 'startColor' => ['rgb' => '4F46E5']], 'alignment' => ['horizontal' => 'center'], ], ]; } }