form->validate(); if ($this->mode === 'create') { $create->execute(new RegisterStudyProgramDTO( name: $this->form->name, code: $this->form->code, level: $this->form->level, status: $this->form->status, facultyId: (int) $this->form->faculty_id, externalId: (int) $this->form->external_id, )); } elseif ($this->mode === 'update') { $update->execute($this->studyProgram, new AdjustStudyProgramDTO( level: $this->form->level, status: $this->form->status, )); } $this->success($this->message); $this->dispatch('hide-studyprogram-form-modal'); $this->js("LaravelDataTables['studyprogram-table'].ajax.reload(null, false)"); $this->form->reset(); $this->form->resetValidation(); $this->reset('id', 'mode'); } #[Computed] public function studyProgram(): ?StudyProgram { return $this->id ? StudyProgram::where('ulid', $this->id)->first() : null; } public function show(int|string $id): void { $this->id = $id; $this->mode = 'update'; $this->form->fill($this->studyProgram->only(['name', 'code', 'level', 'status', 'faculty_id', 'external_id'])); } public function hide(): void { $this->form->reset(); $this->form->resetValidation(); $this->reset('id', 'mode'); } };