form->validate($this->form->rules($this->id ?? 0, $this->mode === 'update')); if ($this->mode === 'create') { $create->execute(new ProvisionUserDTO( name: $this->form->name, email: $this->form->email, password: $this->form->password, role: $this->form->role_name, )); } elseif ($this->mode === 'update') { $update->execute($this->user, new UpdateUserIdentityDTO( name: $this->form->name, email: $this->form->email, )); } $this->success($this->message); $this->dispatch('hide-user-form-modal'); $this->js("LaravelDataTables['user-table'].ajax.reload(null, false)"); } #[Computed] public function user(): ?User { return $this->id ? User::where('ulid', $this->id)->first() : null; } public function show(int|string $id): void { $this->id = $id; $this->mode = 'update'; $this->form->fill($this->user->only(['name', 'email'])); $this->form->role_name = $this->user->role_name; } public function hide(): void { $this->form->reset(); $this->form->resetValidation(); $this->reset('id', 'mode'); } };