user(); $context = app(CustomerCompanyContext::class); $selectedCompanyId = $context->selectedCompanyId($user); $selectedCompany = $context->selectedCompany($user); $pressReleaseQuery = PressRelease::withoutGlobalScopes() ->where('user_id', $user->id) ->when($selectedCompanyId !== null, fn ($query) => $query->where('company_id', $selectedCompanyId)); $myPRs = (clone $pressReleaseQuery) ->selectRaw('status, count(*) as count') ->groupBy('status') ->pluck('count', 'status'); $recent = (clone $pressReleaseQuery) ->with('company:id,name') ->latest() ->limit(5) ->get(['id', 'title', 'status', 'company_id', 'created_at']); return [ 'user' => $user, 'selectedCompany' => $selectedCompany, 'stats' => [ 'total' => (clone $pressReleaseQuery)->count(), 'published' => $myPRs->get('published', 0), 'review' => $myPRs->get('review', 0), 'draft' => $myPRs->get('draft', 0), ], 'qualityHints' => $this->qualityHints($user, $selectedCompany, $pressReleaseQuery), 'recent' => $recent, 'companies' => $context->companiesFor($user), ]; } private function qualityHints(User $user, ?Company $selectedCompany, Builder $pressReleaseQuery): array { $hints = []; if (! $user->profile()->exists()) { $hints[] = [ 'color' => 'amber', 'icon' => 'user', 'title' => __('Profil unvollständig'), 'description' => __('Ergänzen Sie Ihre Profildaten für eine sauberere Kundenakte.'), 'href' => route('me.profile').'#profil', 'action' => __('Profil öffnen'), ]; } if (! $user->billingAddress()->exists()) { $hints[] = [ 'color' => 'amber', 'icon' => 'archive-box', 'title' => __('Rechnungsadresse fehlt'), 'description' => __('Hinterlegen Sie eine Rechnungsadresse, damit spätere Buchungen sauber abgerechnet werden können.'), 'href' => route('me.profile').'#rechnungsadresse', 'action' => __('Rechnungsadresse ergänzen'), ]; } if ($selectedCompany) { $contactsCount = Contact::withoutGlobalScopes() ->where('company_id', $selectedCompany->id) ->count(); if ($contactsCount === 0) { $hints[] = [ 'color' => 'blue', 'icon' => 'user-group', 'title' => __('Keine Pressekontakte hinterlegt'), 'description' => __('Ergänzen Sie Pressekontakte für diese Firma.'), 'href' => route('me.press-kits.show', $selectedCompany->id), 'action' => __('Firma öffnen'), ]; } } else { $unassignedPressReleasesCount = (clone $pressReleaseQuery) ->whereNull('company_id') ->count(); if ($unassignedPressReleasesCount > 0) { $hints[] = [ 'color' => 'amber', 'icon' => 'newspaper', 'title' => trans_choice(':count Pressemitteilung ohne Firma|:count Pressemitteilungen ohne Firma', $unassignedPressReleasesCount, ['count' => $unassignedPressReleasesCount]), 'description' => __('Ordnen Sie Legacy-Pressemitteilungen einer Firma zu, damit Portal und Pressekontakte eindeutig sind.'), 'href' => route('me.press-releases.index', ['company' => 'unassigned']), 'action' => __('Pressemitteilungen prüfen'), ]; } } return $hints; } }; ?>
{{ $pr->title }}
{{ $pr->company?->name ?? '–' }} · {{ $pr->created_at->format('d.m.Y') }}
{{ $company->name }}