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