year = $year; $this->month = $month; $this->date = $date; } public function collection() { $query = Cooperation::with(['media', 'mediaOrder']); if (is_role(['3'])) { $mediaId = Auth::user()->company->media->id; $query->whereHas('proposals', function ($q) use ($mediaId) { $q->where('status', 1) ->where('media_id', $mediaId); }); } if ($this->year) { $query->whereYear('created_at', $this->year); } if ($this->month) { $monthYear = Carbon::parse($this->month); $query->whereYear('created_at', $monthYear->year) ->whereMonth('created_at', $monthYear->month); } if ($this->date) { $query->whereDate('created_at', $this->date); } return $query->get(); } public function map($cooperation): array { return [ $this->no++, $cooperation->name, Carbon::parse($cooperation->start_date)->locale('id')->translatedFormat('l, d F Y'), Carbon::parse($cooperation->end_date)->locale('id')->translatedFormat('l, d F Y'), strip_tags($cooperation->description), $cooperation->media->pluck('name')->implode(', '), Carbon::parse($cooperation->created_at)->locale('id')->translatedFormat('l, d F Y'), ]; } public function headings(): array { return [ ['Data Rekap Konten', '', '', '', '', '', ''], ['NO', 'Nama Kerja Sama', 'Tanggal Mulai', 'Tanggal Selesai', 'Deskripsi', 'Media', 'Dibuat Pada'] ]; } public function styles(Worksheet $sheet) { $sheet->mergeCells('A1:G1'); // A1 sampai G1 digabung // Set alignment untuk pusat horizontal dan vertikal $sheet->getStyle('A1:G1')->getAlignment()->setHorizontal('center'); $sheet->getStyle('A1:G1')->getAlignment()->setVertical('center'); $sheet->getColumnDimension('A')->setWidth(7); // Set column A width $sheet->getColumnDimension('B')->setAutoSize(true); $sheet->getColumnDimension('C')->setAutoSize(true); $sheet->getColumnDimension('D')->setAutoSize(true); $sheet->getColumnDimension('E')->setAutoSize(true); $sheet->getColumnDimension('F')->setAutoSize(true); $sheet->getStyle('F:F')->getAlignment()->setWrapText(true); $sheet->getColumnDimension('G')->setAutoSize(true); // Menambahkan gaya lain jika diperlukan $sheet->getStyle('A1:G1')->getFont()->setBold(true); $sheet->getStyle('A1:G1')->getFont()->setSize(14); } }