$this->resolveAdmissionScheduleId($rawData['jalur'], $rawData['angkatan']), 'academic_program_id' => $this->resolveAcademicProgramId($rawData['kode_Skuliah']), 'study_program_id' => $this->resolveStudyProgramId($rawData['kode_prodi']), 'fee_type_id'=> $this->resolveFeeTypeId($rawData['kode_Jtagihan']), 'amount' => $rawData['nominal_TRFtagihan'], ]; } public function updateOrCreateDomainState(array $payload, ?Model $existingModel = null): void { $this->setUpAdmissionFeeRates->execute(new AdmissionFeeRatesDTO( academicProgramId: $payload['academic_program_id'], admissionScheduleId: $payload['admission_schedule_id'], studyProgramId: $payload['study_program_id'], feeTypeId: $payload['fee_type_id'], amount: $payload['amount'], )); } /** * @return class-string */ public function getModelClass(): string { return FeeRate::class; } public function resolveAdmissionScheduleId(string $admissionTrackSlug, int $yearStudy): int { $key = hex2bin(md5("{$admissionTrackSlug}-{$yearStudy}") ); if (!isset(self::$cache['admission_schedule'][$key])) { self::$cache['admission_schedule'][$key] = AdmissionSchedule::query() ->whereHas( 'admissionTrack', fn($builder) => $builder->where('slug', str($admissionTrackSlug)->slug()) )->whereHas( 'term', fn($builder) => $builder->where('year_study', $yearStudy) )->first()?->id; } return self::$cache['admission_schedule'][$key]; } public function resolveStudyProgramId($code): int { if (!isset(self::$cache['study_program'][$code])) { self::$cache['study_program'][$code] = StudyProgram::where('code', $code)->first()?->id; } return self::$cache['study_program'][$code]; } public function resolveFeeTypeId(string $code): int { $key = hex2bin(md5($code)); if (!isset(self::$cache['fee_type'][$key])) { self::$cache['fee_type'][$key] = FeeType::where('code', $code)->first()?->id; } return self::$cache['fee_type'][$key]; } public function resolveAcademicProgramId(string $code): int { $key = hex2bin(md5($code)); if (!isset(self::$cache['academic_program'][$key])) { self::$cache['academic_program'][$key] = AcademicProgram::where('code', $code)->first()?->id; } return self::$cache['academic_program'][$key]; } }