authorize('catalog.manage'); if ($vatRate === null) { return; } $summary = $priceList->findVatRate($vatRate); abort_if($summary === null, 404); $this->vatRateId = $summary->id; $this->isDefault = $summary->isDefault; $this->name = $summary->name; $this->percentage = (new VatPercentage($summary->basisPoints))->inputValue(); } public function save(AddVatRate $addVatRate, UpdateVatRate $updateVatRate): void { $this->authorize('catalog.manage'); $this->validate( ['name' => ['required', 'string', 'max:100'], 'percentage' => ['required', 'string', 'max:10'], 'makeDefault' => ['boolean']], [ 'name.required' => __('catalog.errors.name_required'), 'name.max' => __('catalog.errors.invalid_name'), 'percentage.required' => __('catalog.errors.vat_percentage_required'), 'percentage.max' => __('catalog.errors.invalid_vat_percentage'), ], ); try { if ($this->vatRateId === null) { $addVatRate->execute($this->name, $this->percentage, $this->makeDefault); session()->flash('status', __('catalog.status.created', ['name' => trim($this->name)])); } else { $updateVatRate->execute($this->vatRateId, $this->name, $this->percentage, $this->makeDefault); session()->flash('status', __('catalog.status.updated', ['name' => trim($this->name)])); } } catch (VatRateNotFound) { abort(404); } catch (InvalidCatalogName) { $this->addError('name', __('catalog.errors.invalid_name')); return; } catch (VatRateNameTaken) { $this->addError('name', __('catalog.errors.vat_rate_name_taken')); return; } catch (InvalidVatPercentage) { $this->addError('percentage', __('catalog.errors.invalid_vat_percentage')); return; } $this->redirectRoute('catalog.prices', navigate: true); } public function heading(): string { return __($this->vatRateId === null ? 'catalog.vat_rates.create_title' : 'catalog.vat_rates.edit_title'); } public function render(): mixed { return $this->view()->title($this->heading()); } }; ?>
{{ $this->heading() }} @if ($vatRateId !== null)

{{ __('catalog.vat_rates.change_help') }}

@endif
@if ($isDefault)

{{ __('catalog.vat_rates.is_default_help') }}

@else

{{ __('catalog.vat_rates.make_default_help') }}

@endif