value.','.Portal::Presseecho->value.','.Portal::Businessportal24->value)] public string $portal = Portal::Both->value; #[Validate('nullable|in:de,en')] public ?string $language = null; public bool $isGlobal = false; public bool $isActive = true; #[Validate('integer|min:0|max:1000')] public int $priority = 0; /** @var array */ public array $categoryIds = []; public function mount(int $id): void { $code = FooterCode::query() ->with('categories:id') ->findOrFail($id); $this->id = $code->id; $this->title = $code->title; $this->content = $code->content; $this->portal = $code->portal->value; $this->language = $code->language; $this->isGlobal = $code->is_global; $this->isActive = $code->is_active; $this->priority = $code->priority; $this->categoryIds = $code->categories->pluck('id')->all(); } public function save(): void { $this->validate(); $code = FooterCode::query()->findOrFail($this->id); DB::transaction(function () use ($code): void { $code->update([ 'title' => $this->title, 'content' => $this->content, 'portal' => $this->portal, 'language' => $this->language, 'is_global' => $this->isGlobal, 'is_active' => $this->isActive, 'priority' => $this->priority, ]); $code->categories()->sync( $this->isGlobal ? [] : $this->categoryIds, ); }); session()->flash('success', __('Footer-Code wurde aktualisiert.')); $this->redirect(route('admin.footer-codes.index'), navigate: true); } public function delete(): void { $code = FooterCode::query()->findOrFail($this->id); $code->delete(); session()->flash('success', __('Footer-Code wurde gelöscht.')); $this->redirect(route('admin.footer-codes.index'), navigate: true); } public function with(): array { return [ 'portalOptions' => Portal::cases(), 'categoryOptions' => Category::query() ->with(['translations' => fn ($q) => $q->where('locale', 'de')]) ->orderBy('id') ->get() ->map(fn (Category $cat) => [ 'id' => $cat->id, 'name' => $cat->translations->first()?->name ?? '#'.$cat->id, 'portal' => $cat->portal->value, ]), ]; } }; ?>
{{-- ============== PAGE HEADER ============== --}}
{{ __('Admin Backend') }} {{ __('Administration · Footer-Codes') }} ID #{{ $id }} @if ($isGlobal) {{ __('Global') }} @endif @if ($isActive) {{ __('Aktiv') }} @else {{ __('Inaktiv') }} @endif

{{ __('Footer-Code bearbeiten') }}

{{ $title }}

{{ __('Zurück') }}
{{ __('Stammdaten') }}
@foreach ($portalOptions as $option) @endforeach
{{ __('Sichtbarkeit') }}
@if (! $isGlobal)
{{ __('Kategorie-Zuordnung') }}
@forelse ($categoryOptions as $option) @empty

{{ __('Keine Kategorien vorhanden.') }}

@endforelse
@endif
{{ __('Danger Zone & Aktionen') }}
{{ __('Löschen') }}
{{ __('Abbrechen') }} {{ __('Speichern') }}