startDate = $startDate; $this->endDate = $endDate; } /** * @return \Illuminate\Support\Collection */ public function collection() { return Dioksida::where('id_alat', 4) // Menambahkan filter untuk id_alat = 4 ->whereBetween('created_at', [$this->startDate, $this->endDate]) ->select('id_dioksida', 'created_at', 'nilai_dioksida') ->orderBy('created_at') ->get(); } public function headings(): array { return [ 'No', 'Tanggal', 'Nilai Dioksida', ]; } /** * @param mixed $row */ public function map($row): array { static $number = 0; $number++; return [ $number, $row->created_at, $row->nilai_dioksida, ]; } /** * @return array */ public function styles(Worksheet $sheet) { // Apply styles to the header row $sheet->getStyle('A1:C1')->applyFromArray([ 'font' => [ 'bold' => true, 'color' => ['argb' => Color::COLOR_WHITE], ], 'fill' => [ 'fillType' => Fill::FILL_SOLID, 'startColor' => ['argb' => 'FF4CAF50'], ], ]); // Apply borders to all cells $sheet->getStyle('A1:C' . ($sheet->getHighestRow())) ->getBorders() ->getAllBorders() ->setBorderStyle(Border::BORDER_THIN) ->setColor(new Color(Color::COLOR_BLACK)); return []; } }