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 save(): void { $this->validate(); DB::transaction(function (): void { $code = FooterCode::create([ 'title' => $this->title, 'content' => $this->content, 'portal' => $this->portal, 'language' => $this->language, 'is_global' => $this->isGlobal, 'is_active' => $this->isActive, 'priority' => $this->priority, ]); if (! $this->isGlobal && ! empty($this->categoryIds)) { $code->categories()->sync($this->categoryIds); } }); session()->flash('success', __('Footer-Code wurde angelegt.')); $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 ============== --}}
{{ __('Stammdaten') }}
@foreach ($portalOptions as $option) @endforeach
{{ __('Sichtbarkeit') }}
@if (! $isGlobal)
{{ __('Kategorie-Zuordnung') }}

{{ __('Nur Pressemitteilungen in diesen Kategorien zeigen den Footer-Code.') }}

@forelse ($categoryOptions as $option) @empty

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

@endforelse
@endif
{{ __('Abbrechen') }} {{ __('Speichern') }}