authorize('catalog.manage'); if ($service !== null) { $summary = $catalogQueries->findService($service); abort_if($summary === null, 404); $this->serviceId = $summary->id; $this->form->name = $summary->name; $serviceUnit = $summary->serviceUnitId; } $unit = $serviceUnit === null ? null : $catalogQueries->findServiceUnit($serviceUnit); abort_if($unit === null || ($unit->isShared && $this->serviceId === null), 404); $this->serviceUnitId = $unit->id; $this->unitName = $unit->name; } public function save(AddService $addService, RenameCatalogItem $renameItem): void { $this->authorize('catalog.manage'); $name = $this->form->validatedName(); try { if ($this->serviceId === null) { $addService->execute((int) $this->serviceUnitId, $name); session()->flash('status', __('catalog.status.created', ['name' => trim($name)])); } else { $renameItem->execute(CatalogLevel::Service, $this->serviceId, $name); session()->flash('status', __('catalog.status.updated', ['name' => trim($name)])); } } catch (CatalogItemNotFound) { abort(404); } catch (DomainException $exception) { $this->form->showDomainError($exception); return; } $this->redirectRoute('catalog.index', navigate: true); } public function heading(): string { return __($this->serviceId === null ? 'catalog.services.create_title' : 'catalog.services.edit_title'); } public function render(): mixed { return $this->view()->title($this->heading().' – '.$this->unitName); } }; ?>
{{ __('catalog.fields.service_unit') }}: {{ $unitName }}
@endif