authorize('users:manage'); $this->id = $id; if (! User::query()->whereKey($id)->exists()) { session()->flash('error', __('Der angeforderte Benutzer wurde nicht gefunden.')); $this->redirect(route('admin.users.index'), navigate: true); return; } } public function grantCredits(): void { $this->authorize('users:manage'); $this->validate([ 'grantCreditsAmount' => ['required', 'integer', 'min:1', 'max:100000'], 'grantCreditsNote' => ['nullable', 'string', 'max:240'], ]); $user = User::query()->findOrFail($this->id); app(AdminGrantService::class)->grantCredits( $user, $this->grantCreditsAmount, auth()->user(), trim($this->grantCreditsNote) ?: null, ); Flux::toast( text: __(':count Credits gutgeschrieben.', ['count' => $this->grantCreditsAmount]), variant: 'success', ); $this->reset('grantCreditsNote'); } public function grantFreePressReleases(): void { $this->authorize('users:manage'); $this->validate([ 'grantPmCount' => ['required', 'integer', 'min:1', 'max:100'], 'grantPmNote' => ['nullable', 'string', 'max:240'], ]); $user = User::query()->findOrFail($this->id); app(AdminGrantService::class)->grantFreePressReleases( $user, $this->grantPmCount, auth()->user(), trim($this->grantPmNote) ?: null, ); Flux::toast( text: __(':count freie Pressemitteilung(en) gutgeschrieben.', ['count' => $this->grantPmCount]), variant: 'success', ); $this->reset('grantPmNote'); } public function companyUserRoleLabel(?string $role): string { return match ($role ?? 'member') { 'owner' => __('Inhaber'), 'responsible' => __('Verantwortlich'), 'member' => __('Mitglied'), default => (string) ($role ?? 'member'), }; } public function with(): array { $user = User::query() ->with([ 'roles' => fn ($query) => $query->orderBy('name'), 'companies' => fn ($query) => $query ->select(['companies.id', 'companies.name', 'companies.slug', 'companies.email', 'companies.phone', 'companies.portal', 'companies.is_active']) ->withCount('contacts') ->orderBy('name'), 'companies.contacts' => fn ($query) => $query ->select(['contacts.id', 'contacts.company_id', 'contacts.portal', 'contacts.first_name', 'contacts.last_name', 'contacts.responsibility', 'contacts.email', 'contacts.phone']) ->orderBy('last_name') ->orderBy('first_name') ->limit(10), 'billingAddress', ]) ->find($this->id); return [ 'user' => $user, 'creditBalance' => $user ? app(CreditWalletService::class)->balance($user) : 0, 'openPmPurchases' => $user?->openSinglePurchaseCount() ?? 0, 'quotaRemaining' => $user?->pressReleaseQuotaRemaining(), ]; } }; ?>
{{ __('Keine Rollen hinterlegt') }}
@endforelse{{ __('Wird als bezahlter 0-€-Einzelkauf verbucht und beim Veröffentlichen regulär eingelöst.') }}
{{ __('Keine Rechnungsadresse hinterlegt') }}
@endif{{ __('Kontakte sind die Ansprechpartner der verknüpften Firmen (wie in der Bearbeiten-Ansicht).') }}
@forelse ($user->companies as $company){{ __(':count weitere Kontakte werden hier nicht geladen. Öffne die Firma, um alle Kontakte zu sehen.', ['count' => $company->contacts_count - $company->contacts->count()]) }}
@endif{{ __('Keine Kontakte bei dieser Firma') }}
@endif{{ __('Keine Firmen verknüpft') }}
@endforelse