$row['pertemuan'], 'kelas_id' => $row['kelas_id'], 'tanggal' => $this->transformDate($row['tanggal'] ?? null), 'materi' => $row['materi'] ?? null, 'catatan' => $row['catatan'] ?? null, 'status' => $row['status'] ?? null, ]); } private function transformDate($date) { if (!$date) { return null; } // Jika tanggal dalam format Excel (angka serial), ubah ke format tanggal if (is_numeric($date)) { return Carbon::instance(Date::excelToDateTimeObject($date))->format('Y-m-d'); } // Jika tanggal dalam format teks, coba parsing try { return Carbon::parse($date)->format('Y-m-d'); } catch (\Exception $e) { return null; // Jika gagal, set ke null } } public function rules(): array { return [ 'kelas_id' => 'required', ]; } public function customValidationMessages() { return [ 'kelas_id.required' => 'ID kelas tidak ditemukan', ]; } }