sortBy === $column) { $this->sortDir = $this->sortDir === 'asc' ? 'desc' : 'asc'; } else { $this->sortBy = $column; $this->sortDir = 'asc'; } $this->resetPage(); } public function updatedSearch(): void { $this->resetPage(); } public function updatedStatusFilter(): void { $this->resetPage(); } public function updatedCompanyFilter(): void { $this->resetPage(); } public function submitForReview(int $id): void { $pr = $this->findMyPR($id); if (! $pr) { return; } try { app(PressReleaseService::class)->submitForReview($pr); session()->flash('success', __('Pressemitteilung zur Prüfung eingereicht.')); } catch (BlacklistViolationException $e) { session()->flash('error', __('Pressemitteilung wurde automatisch abgelehnt: unzulässiges Wort ":word".', ['word' => $e->word])); } catch (\LogicException $e) { session()->flash('error', $e->getMessage()); } } public function with(): array { $userId = auth()->id(); $context = app(CustomerCompanyContext::class); $selectedCompanyId = $context->selectedCompanyId(auth()->user()); $prs = PressRelease::withoutGlobalScopes() ->where('user_id', $userId) ->with('company:id,name') ->when($selectedCompanyId !== null, fn ($q) => $q->where('company_id', $selectedCompanyId)) ->when($selectedCompanyId === null && $this->companyFilter === 'assigned', fn ($q) => $q->whereNotNull('company_id')) ->when($selectedCompanyId === null && $this->companyFilter === 'unassigned', fn ($q) => $q->whereNull('company_id')) ->when(filled($this->search), function ($q): void { $term = $this->search; $q->where('title', 'like', '%'.$term.'%'); }) ->when($this->statusFilter !== 'all', fn ($q) => $q->where('status', $this->statusFilter)) ->orderBy(in_array($this->sortBy, ['title', 'status', 'created_at']) ? $this->sortBy : 'created_at', $this->sortDir) ->paginate(100); return [ 'pressReleases' => $prs, 'statusOptions' => PressReleaseStatus::cases(), 'selectedCompany' => $context->selectedCompany(auth()->user()), 'hasGlobalCompanyContext' => $selectedCompanyId === null, ]; } private function findMyPR(int $id): ?PressRelease { return PressRelease::withoutGlobalScopes() ->where('id', $id) ->where('user_id', auth()->id()) ->first(); } }; ?>
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- ============== PAGE HEADER ============== --}}
{{ __('User Backend') }} {{ __('Mein Bereich · Pressemitteilungen') }}

{{ __('Meine Pressemitteilungen') }}

@if ($selectedCompany) {{ __('Gefiltert auf :company', ['company' => $selectedCompany->name]) }} @else {{ __('Übersicht aller PMs Ihres Kundenkontos, mit Filter und Schnellaktionen.') }} @endif

{{ __('Neue Pressemitteilung') }}
{{-- ============== FILTER-PANEL ============== --}}
{{ __('Filter & Suche') }}
@foreach($statusOptions as $s) @endforeach @if($hasGlobalCompanyContext) @endif
{{-- ============== TABELLE-PANEL ============== --}}
{{ __('Alle Pressemitteilungen') }} {{ __(':count Einträge', ['count' => $pressReleases->count()]) }}
{{ __('Titel') }} {{ __('Firma') }} {{ __('Status') }} {{ __('Erstellt') }} {{ __('Aktionen') }} @forelse($pressReleases as $pr)

{{ $pr->title }}

{{ $pr->company?->name ?? '–' }} $pr->status->value === 'published', 'warn' => $pr->status->value === 'review', 'err' => $pr->status->value === 'rejected', 'hub' => in_array($pr->status->value, ['archived', 'draft'], true), ])>{{ $pr->status->label() }} {{ $pr->created_at->format('d.m.Y') }}
@if(in_array($pr->status->value, ['draft', 'rejected'])) @endif
@empty
{{ __('Keine Pressemitteilungen gefunden') }}

{{ __('Passen Sie die Filter an oder erstellen Sie eine neue Pressemitteilung.') }}

{{ __('Neue Pressemitteilung') }}
@endforelse
{{ $pressReleases->links() }}