findSummary($customer); abort_if($summary === null, 404); $this->customerId = $summary->id; $this->form->fillFromSummary($summary); } public function save(RegisterCustomer $registerCustomer, UpdateCustomer $updateCustomer): void { $data = $this->form->toData(); try { if ($this->customerId === null) { $registerCustomer->execute($data); session()->flash('status', __('customers.created', ['name' => $data->name])); } else { $updateCustomer->execute($this->customerId, $data); session()->flash('status', __('customers.updated', ['name' => $data->name])); } } catch (DomainException $exception) { $this->form->showDomainError($exception); return; } $this->redirectRoute('customers.index', navigate: true); } public function render(): mixed { return $this->view()->title(__($this->customerId === null ? 'customers.create_title' : 'customers.edit_title')); } }; ?>