client = Client::find($id); if ($this->client) { $this->clientForm->addClient($this->client); } } catch (Exception $e) { $this->dispatch('notify', message: 'Ocorreu um erro inesperado ao editar o cliente. ' + $e); } } public function edit(ClientService $clientService) { $data = $this->clientForm->validate(); try { if (!$clientService->updateClient($this->client, $data)) { throw new Exception('O serviço não confirmou a atualização.'); } $this->dispatch('client-updated'); $this->dispatch('notify', message: $this->clientForm->client_name . ' atualizado com sucesso!'); } catch (Exception $e) { $this->dispatch('notify', message: 'Falha na edição: ' . $e->getMessage(), type: 'error'); } } public function render() { return view('livewire.admin.clients.edit-client'); } }