12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
421
resources/views/livewire/admin/users/create.blade.php
Normal file
421
resources/views/livewire/admin/users/create.blade.php
Normal file
|
|
@ -0,0 +1,421 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Enums\RegistrationType;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use App\Services\Admin\AdminPerformanceCache;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
new #[Layout('components.layouts.app'), Title('Benutzer anlegen')] class extends Component
|
||||
{
|
||||
public string $name = '';
|
||||
|
||||
public string $email = '';
|
||||
|
||||
public string $portal = '';
|
||||
|
||||
public string $registrationType = '';
|
||||
|
||||
public string $language = 'de';
|
||||
|
||||
public bool $isActive = true;
|
||||
|
||||
public bool $isSuperAdmin = false;
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $selectedRoles = [];
|
||||
|
||||
/** @var array<int, int> */
|
||||
public array $linkedCompanyIds = [];
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $companyRoles = [];
|
||||
|
||||
public string $companyLookup = '';
|
||||
|
||||
public ?int $selectedLookupCompanyId = null;
|
||||
|
||||
/**
|
||||
* @var array{
|
||||
* salutation_key:?string,
|
||||
* title:?string,
|
||||
* name:?string,
|
||||
* address1:?string,
|
||||
* address2:?string,
|
||||
* postal_code:?string,
|
||||
* city:?string,
|
||||
* country_code:?string
|
||||
* }
|
||||
*/
|
||||
public array $billing = [
|
||||
'salutation_key' => null,
|
||||
'title' => null,
|
||||
'name' => null,
|
||||
'address1' => null,
|
||||
'address2' => null,
|
||||
'postal_code' => null,
|
||||
'city' => null,
|
||||
'country_code' => null,
|
||||
];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->portal = Portal::Both->value;
|
||||
$this->registrationType = RegistrationType::ExistingLegacy->value;
|
||||
}
|
||||
|
||||
public function updatedSelectedLookupCompanyId(): void
|
||||
{
|
||||
if ($this->selectedLookupCompanyId) {
|
||||
$this->addLinkedCompany();
|
||||
}
|
||||
}
|
||||
|
||||
public function addLinkedCompany(): void
|
||||
{
|
||||
if (! $this->selectedLookupCompanyId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->linkedCompanyIds = array_map('intval', $this->linkedCompanyIds);
|
||||
|
||||
if (! in_array($this->selectedLookupCompanyId, $this->linkedCompanyIds, true)) {
|
||||
$this->linkedCompanyIds[] = $this->selectedLookupCompanyId;
|
||||
}
|
||||
|
||||
$this->companyRoles[$this->selectedLookupCompanyId] ??= 'member';
|
||||
$this->companyLookup = '';
|
||||
$this->selectedLookupCompanyId = null;
|
||||
}
|
||||
|
||||
public function removeLinkedCompany(int $companyId): void
|
||||
{
|
||||
$this->linkedCompanyIds = array_values(array_filter(
|
||||
$this->linkedCompanyIds,
|
||||
fn (int|string $id): bool => (int) $id !== $companyId
|
||||
));
|
||||
|
||||
unset($this->companyRoles[$companyId]);
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', Rule::unique('users', 'email')],
|
||||
'portal' => ['required', Rule::in(array_map(static fn (Portal $portal): string => $portal->value, Portal::cases()))],
|
||||
'registrationType' => ['required', Rule::in(array_map(static fn (RegistrationType $type): string => $type->value, RegistrationType::cases()))],
|
||||
'language' => ['required', 'string', Rule::in(['de', 'en'])],
|
||||
'selectedRoles' => ['required', 'array', 'min:1'],
|
||||
'selectedRoles.*' => ['string', Rule::exists('roles', 'name')],
|
||||
'linkedCompanyIds' => ['array'],
|
||||
'linkedCompanyIds.*' => ['integer', Rule::exists('companies', 'id')],
|
||||
'companyRoles' => ['array'],
|
||||
'companyRoles.*' => ['string', Rule::in(['member', 'responsible', 'owner'])],
|
||||
'billing.salutation_key' => ['nullable', 'string', 'max:20'],
|
||||
'billing.title' => ['nullable', 'string', 'max:80'],
|
||||
'billing.name' => ['nullable', 'string', 'max:255'],
|
||||
'billing.address1' => ['nullable', 'string', 'max:255'],
|
||||
'billing.address2' => ['nullable', 'string', 'max:255'],
|
||||
'billing.postal_code' => ['nullable', 'string', 'max:20'],
|
||||
'billing.city' => ['nullable', 'string', 'max:120'],
|
||||
'billing.country_code' => ['nullable', 'string', 'size:2'],
|
||||
]);
|
||||
|
||||
$user = User::query()->create([
|
||||
'name' => $validated['name'],
|
||||
'email' => $validated['email'],
|
||||
'portal' => $validated['portal'],
|
||||
'registration_type' => $validated['registrationType'],
|
||||
'language' => $validated['language'],
|
||||
'is_active' => $this->isActive,
|
||||
'is_super_admin' => $this->isSuperAdmin,
|
||||
'password' => null,
|
||||
]);
|
||||
|
||||
$user->syncRoles($validated['selectedRoles']);
|
||||
|
||||
$companySyncPayload = [];
|
||||
foreach ($validated['linkedCompanyIds'] as $companyId) {
|
||||
$companySyncPayload[$companyId] = [
|
||||
'role' => $validated['companyRoles'][$companyId] ?? 'member',
|
||||
];
|
||||
}
|
||||
$user->companies()->sync($companySyncPayload);
|
||||
|
||||
if ($this->billingIsComplete()) {
|
||||
$user->billingAddress()->create([
|
||||
'salutation_key' => $validated['billing']['salutation_key'] ?: null,
|
||||
'title' => $validated['billing']['title'] ?: null,
|
||||
'name' => (string) $validated['billing']['name'],
|
||||
'address1' => (string) $validated['billing']['address1'],
|
||||
'address2' => $validated['billing']['address2'] ?: null,
|
||||
'postal_code' => (string) $validated['billing']['postal_code'],
|
||||
'city' => (string) $validated['billing']['city'],
|
||||
'country_code' => strtoupper((string) $validated['billing']['country_code']),
|
||||
]);
|
||||
}
|
||||
|
||||
session()->flash('success', __('Benutzer wurde angelegt und verknuepft.'));
|
||||
$this->redirect(route('admin.users.edit', $user->id), navigate: true);
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
$companyLookupResults = collect();
|
||||
$companyLookupTerm = trim($this->companyLookup);
|
||||
|
||||
if (mb_strlen($companyLookupTerm) >= 1) {
|
||||
$companyLookupResults = Company::withoutGlobalScopes()
|
||||
->whereNotIn('id', $this->linkedCompanyIds ?: [-1])
|
||||
->where(function ($query) use ($companyLookupTerm): void {
|
||||
if ($this->supportsFullTextSearch($companyLookupTerm)) {
|
||||
$query->whereFullText(['name', 'email', 'slug'], $companyLookupTerm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$query
|
||||
->where('name', 'like', '%'.$companyLookupTerm.'%')
|
||||
->orWhere('slug', 'like', '%'.$companyLookupTerm.'%')
|
||||
->orWhere('email', 'like', '%'.$companyLookupTerm.'%');
|
||||
})
|
||||
->orderBy('name')
|
||||
->limit(50)
|
||||
->get(['id', 'name', 'slug', 'email']);
|
||||
}
|
||||
|
||||
return [
|
||||
'availableRoles' => $this->availableRoles(),
|
||||
'linkedCompanies' => Company::withoutGlobalScopes()
|
||||
->whereIn('id', $this->linkedCompanyIds ?: [-1])
|
||||
->orderBy('name')
|
||||
->get(['id', 'name', 'slug', 'email']),
|
||||
'companyLookupResults' => $companyLookupResults,
|
||||
'salutations' => config('salutations.items', []),
|
||||
'countries' => config('countries.items', []),
|
||||
'portalOptions' => Portal::cases(),
|
||||
'registrationTypeOptions' => RegistrationType::cases(),
|
||||
];
|
||||
}
|
||||
|
||||
private function availableRoles(): Collection
|
||||
{
|
||||
return app(AdminPerformanceCache::class)->remember(AdminPerformanceCache::RoleOptions, AdminPerformanceCache::OptionsTtl, fn () => Role::query()
|
||||
->orderBy('name')
|
||||
->get(['id', 'name']));
|
||||
}
|
||||
|
||||
private function supportsFullTextSearch(string $term): bool
|
||||
{
|
||||
return mb_strlen($term) >= 3
|
||||
&& in_array(DB::connection()->getDriverName(), ['mysql', 'pgsql'], true);
|
||||
}
|
||||
|
||||
protected function billingIsComplete(): bool
|
||||
{
|
||||
return filled($this->billing['name'])
|
||||
&& filled($this->billing['address1'])
|
||||
&& filled($this->billing['postal_code'])
|
||||
&& filled($this->billing['city'])
|
||||
&& filled($this->billing['country_code']);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<form wire:submit="save" class="space-y-6">
|
||||
<flux:card>
|
||||
<flux:heading size="lg">{{ __('Benutzer anlegen') }}</flux:heading>
|
||||
<flux:subheading>{{ __('Rollen, Firmen und optional Rechnungsadresse direkt mitsetzen.') }}</flux:subheading>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Basisdaten') }}</flux:heading>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Name') }}</flux:label>
|
||||
<flux:input wire:model="name" />
|
||||
<flux:error name="name" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('E-Mail') }}</flux:label>
|
||||
<flux:input wire:model="email" type="email" />
|
||||
<flux:error name="email" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Portal') }}</flux:label>
|
||||
<flux:select wire:model="portal">
|
||||
@foreach($portalOptions as $portalOption)
|
||||
<option value="{{ $portalOption->value }}">{{ $portalOption->label() }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
<flux:error name="portal" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Registrierungstyp') }}</flux:label>
|
||||
<flux:select wire:model="registrationType">
|
||||
@foreach($registrationTypeOptions as $registrationTypeOption)
|
||||
<option value="{{ $registrationTypeOption->value }}">{{ $registrationTypeOption->label() }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
<flux:error name="registrationType" />
|
||||
</flux:field>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-6">
|
||||
<flux:checkbox wire:model="isActive" label="{{ __('Aktiv') }}" />
|
||||
<flux:checkbox wire:model="isSuperAdmin" label="{{ __('Super Admin') }}" />
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Rollenzuweisung') }}</flux:heading>
|
||||
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
@foreach($availableRoles as $role)
|
||||
<flux:checkbox wire:model="selectedRoles" value="{{ $role->name }}" label="{{ $role->name }}" />
|
||||
@endforeach
|
||||
</div>
|
||||
<flux:error name="selectedRoles" class="mt-4" />
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Firmenverknüpfung') }}</flux:heading>
|
||||
|
||||
<div class="mb-4">
|
||||
<flux:select
|
||||
wire:model.live="selectedLookupCompanyId"
|
||||
variant="combobox"
|
||||
:filter="false"
|
||||
placeholder="{{ __('Firma suchen und hinzufügen…') }}"
|
||||
>
|
||||
<x-slot name="input">
|
||||
<flux:select.input
|
||||
wire:model.live.debounce.300ms="companyLookup"
|
||||
placeholder="{{ __('Name, Slug oder E-Mail…') }}"
|
||||
/>
|
||||
</x-slot>
|
||||
|
||||
@foreach($companyLookupResults as $company)
|
||||
<flux:select.option :value="$company->id" wire:key="create-company-{{ $company->id }}">
|
||||
{{ $company->name }}@if($company->email)<span class="ml-1 text-zinc-400">· {{ $company->email }}</span>@endif
|
||||
</flux:select.option>
|
||||
@endforeach
|
||||
|
||||
<x-slot name="empty">
|
||||
<flux:select.option.empty>
|
||||
@if(blank(trim($companyLookup)))
|
||||
{{ __('Mindestens 1 Zeichen eingeben…') }}
|
||||
@else
|
||||
{{ __('Keine Firma gefunden.') }}
|
||||
@endif
|
||||
</flux:select.option.empty>
|
||||
</x-slot>
|
||||
</flux:select>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3">
|
||||
@forelse($linkedCompanies as $company)
|
||||
<div class="grid gap-3 rounded-lg border border-zinc-200 p-3 dark:border-zinc-700 sm:grid-cols-[1fr,160px,auto] sm:items-center">
|
||||
<div>
|
||||
<flux:text weight="semibold">{{ $company->name }}</flux:text>
|
||||
<flux:text class="text-sm text-zinc-500">{{ $company->slug }}</flux:text>
|
||||
</div>
|
||||
|
||||
<flux:select wire:model="companyRoles.{{ $company->id }}">
|
||||
<option value="member">{{ __('Member') }}</option>
|
||||
<option value="responsible">{{ __('Responsible') }}</option>
|
||||
<option value="owner">{{ __('Owner') }}</option>
|
||||
</flux:select>
|
||||
|
||||
<flux:button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
icon="x-mark"
|
||||
wire:click="removeLinkedCompany({{ $company->id }})"
|
||||
>
|
||||
{{ __('Entfernen') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
@empty
|
||||
<flux:text class="text-sm text-zinc-500">{{ __('Noch keine Firma verknüpft.') }}</flux:text>
|
||||
@endforelse
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Rechnungsadresse (optional)') }}</flux:heading>
|
||||
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Anrede') }}</flux:label>
|
||||
<flux:select wire:model="billing.salutation_key">
|
||||
<option value="">{{ __('Bitte wählen') }}</option>
|
||||
@foreach($salutations as $key => $labels)
|
||||
<option value="{{ $key }}">{{ $labels['de'] ?? $key }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Titel') }}</flux:label>
|
||||
<flux:input wire:model="billing.title" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field class="sm:col-span-2">
|
||||
<flux:label>{{ __('Rechnungsname') }}</flux:label>
|
||||
<flux:input wire:model="billing.name" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field class="sm:col-span-2">
|
||||
<flux:label>{{ __('Adresse Zeile 1') }}</flux:label>
|
||||
<flux:input wire:model="billing.address1" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field class="sm:col-span-2">
|
||||
<flux:label>{{ __('Adresse Zeile 2') }}</flux:label>
|
||||
<flux:input wire:model="billing.address2" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('PLZ') }}</flux:label>
|
||||
<flux:input wire:model="billing.postal_code" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Stadt') }}</flux:label>
|
||||
<flux:input wire:model="billing.city" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Land') }}</flux:label>
|
||||
<flux:select wire:model="billing.country_code">
|
||||
<option value="">{{ __('Bitte wählen') }}</option>
|
||||
@foreach($countries as $countryCode => $countryName)
|
||||
<option value="{{ $countryCode }}">{{ $countryName }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:button variant="ghost" href="{{ route('admin.users.index') }}" wire:navigate>
|
||||
{{ __('Abbrechen') }}
|
||||
</flux:button>
|
||||
<flux:button type="submit" variant="primary">
|
||||
{{ __('Benutzer anlegen') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
</form>
|
||||
1224
resources/views/livewire/admin/users/edit.blade.php
Normal file
1224
resources/views/livewire/admin/users/edit.blade.php
Normal file
File diff suppressed because it is too large
Load diff
239
resources/views/livewire/admin/users/show.blade.php
Normal file
239
resources/views/livewire/admin/users/show.blade.php
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new #[Layout('components.layouts.app'), Title('Benutzer anzeigen')] class extends Component
|
||||
{
|
||||
#[Locked]
|
||||
public int $id;
|
||||
|
||||
public function mount(int $id): void
|
||||
{
|
||||
$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 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,
|
||||
];
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="space-y-6">
|
||||
@if (!$user)
|
||||
<flux:card>
|
||||
<flux:heading size="lg">{{ __('Benutzer nicht gefunden') }}</flux:heading>
|
||||
<flux:button class="mt-4" href="{{ route('admin.users.index') }}" wire:navigate>
|
||||
{{ __('Zurück zur Übersicht') }}
|
||||
</flux:button>
|
||||
</flux:card>
|
||||
@else
|
||||
<flux:card>
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div>
|
||||
<flux:heading size="xl">{{ $user->name }}</flux:heading>
|
||||
<flux:text class="text-sm text-zinc-500">{{ $user->email }}</flux:text>
|
||||
<flux:text class="text-xs text-zinc-500">ID: {{ $user->id }}</flux:text>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<flux:button variant="ghost" href="{{ route('admin.users.index') }}" wire:navigate>
|
||||
{{ __('Zurück') }}
|
||||
</flux:button>
|
||||
<flux:button icon="pencil" href="{{ route('admin.users.edit', $user->id) }}" wire:navigate>
|
||||
{{ __('Bearbeiten') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-4">
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Portal') }}</flux:text>
|
||||
<flux:text weight="semibold">{{ $user->portal?->label() ?? '-' }}</flux:text>
|
||||
</flux:card>
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Typ') }}</flux:text>
|
||||
<flux:text weight="semibold">{{ $user->registration_type?->label() ?? '-' }}</flux:text>
|
||||
</flux:card>
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Status') }}</flux:text>
|
||||
@if ($user->is_active)
|
||||
<flux:badge color="green" size="sm">{{ __('Aktiv') }}</flux:badge>
|
||||
@else
|
||||
<flux:badge color="red" size="sm">{{ __('Inaktiv') }}</flux:badge>
|
||||
@endif
|
||||
</flux:card>
|
||||
<flux:card>
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Letzter Login') }}</flux:text>
|
||||
<flux:text weight="semibold">{{ $user->last_login_at?->format('d.m.Y H:i') ?? __('Nie') }}</flux:text>
|
||||
@if ($user->last_login_ip)
|
||||
<flux:text class="text-xs text-zinc-500">{{ $user->last_login_ip }}</flux:text>
|
||||
@endif
|
||||
</flux:card>
|
||||
</div>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Rollen') }}</flux:heading>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
@forelse($user->roles as $role)
|
||||
<flux:badge color="zinc" size="sm">{{ $role->name }}</flux:badge>
|
||||
@empty
|
||||
<flux:text class="text-sm text-zinc-500">{{ __('Keine Rollen hinterlegt') }}</flux:text>
|
||||
@endforelse
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Rechnungsadresse') }}</flux:heading>
|
||||
@if ($user->billingAddress)
|
||||
<div class="space-y-1">
|
||||
<flux:text>{{ $user->billingAddress->name }}</flux:text>
|
||||
<flux:text>{{ $user->billingAddress->address1 }}</flux:text>
|
||||
@if ($user->billingAddress->address2)
|
||||
<flux:text>{{ $user->billingAddress->address2 }}</flux:text>
|
||||
@endif
|
||||
<flux:text>{{ $user->billingAddress->postal_code }} {{ $user->billingAddress->city }}</flux:text>
|
||||
<flux:text>{{ $user->billingAddress->country_code }}</flux:text>
|
||||
</div>
|
||||
@else
|
||||
<flux:text class="text-sm text-zinc-500">{{ __('Keine Rechnungsadresse hinterlegt') }}</flux:text>
|
||||
@endif
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Verknüpfte Firmen und Kontakte') }}</flux:heading>
|
||||
<flux:subheading class="mb-4">
|
||||
{{ __('Kontakte sind die Ansprechpartner der verknüpften Firmen (wie in der Bearbeiten-Ansicht).') }}
|
||||
</flux:subheading>
|
||||
|
||||
<div class="space-y-4">
|
||||
@forelse($user->companies as $company)
|
||||
<div class="rounded-lg border border-zinc-200 p-4 dark:border-zinc-700">
|
||||
<div class="mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div class="min-w-0 flex-1">
|
||||
@if (\Illuminate\Support\Facades\Route::has('admin.companies.show'))
|
||||
<a href="{{ route('admin.companies.show', $company->id) }}" wire:navigate
|
||||
class="block">
|
||||
<flux:text weight="semibold"
|
||||
class="text-blue-600 hover:underline dark:text-blue-400">
|
||||
{{ $company->name }}
|
||||
</flux:text>
|
||||
</a>
|
||||
@else
|
||||
<flux:text weight="semibold">{{ $company->name }}</flux:text>
|
||||
@endif
|
||||
<flux:text class="text-xs text-zinc-500">{{ $company->slug }}</flux:text>
|
||||
<div class="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-zinc-500">
|
||||
@if ($company->email)
|
||||
<span>{{ $company->email }}</span>
|
||||
@endif
|
||||
@if ($company->phone)
|
||||
<span>{{ $company->phone }}</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<flux:badge color="zinc" size="sm">
|
||||
{{ $this->companyUserRoleLabel($company->pivot?->role ?? 'member') }}
|
||||
</flux:badge>
|
||||
<flux:badge color="zinc" size="sm">
|
||||
{{ $company->portal?->label() ?? '—' }}
|
||||
</flux:badge>
|
||||
@if (!$company->is_active)
|
||||
<flux:badge color="red" size="sm">{{ __('Inaktiv') }}</flux:badge>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($company->contacts->isNotEmpty())
|
||||
<div class="space-y-2">
|
||||
@foreach ($company->contacts as $contact)
|
||||
<div
|
||||
class="flex flex-col gap-2 rounded-md bg-zinc-50 p-2 dark:bg-zinc-900 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="min-w-0">
|
||||
<flux:text class="text-sm" weight="medium">
|
||||
{{ trim(($contact->first_name ?? '') . ' ' . ($contact->last_name ?? '')) ?: __('Kontakt ohne Name') }}
|
||||
</flux:text>
|
||||
<flux:text class="text-xs text-zinc-500">
|
||||
{{ $contact->responsibility ?? __('Keine Rolle hinterlegt') }}
|
||||
</flux:text>
|
||||
<div class="mt-0.5 flex flex-wrap items-center gap-2 text-xs text-zinc-500">
|
||||
@if ($contact->email)
|
||||
<a href="mailto:{{ $contact->email }}"
|
||||
class="text-blue-600 hover:underline dark:text-blue-400">{{ $contact->email }}</a>
|
||||
@endif
|
||||
@if ($contact->phone)
|
||||
<span>{{ $contact->phone }}</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<flux:badge color="zinc" size="sm">
|
||||
{{ $contact->portal?->label() ?? '—' }}</flux:badge>
|
||||
@if (\Illuminate\Support\Facades\Route::has('admin.contacts.edit'))
|
||||
<flux:button size="sm" variant="ghost" icon="pencil"
|
||||
href="{{ route('admin.contacts.edit', $contact->id) }}"
|
||||
wire:navigate>
|
||||
{{ __('Bearbeiten') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@if ($company->contacts_count > $company->contacts->count())
|
||||
<flux:text class="text-xs text-zinc-500">
|
||||
{{ __(':count weitere Kontakte werden hier nicht geladen. Öffne die Firma, um alle Kontakte zu sehen.', ['count' => $company->contacts_count - $company->contacts->count()]) }}
|
||||
</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
<flux:text class="text-xs text-zinc-500">{{ __('Keine Kontakte bei dieser Firma') }}
|
||||
</flux:text>
|
||||
@endif
|
||||
</div>
|
||||
@empty
|
||||
<flux:text class="text-sm text-zinc-500">{{ __('Keine Firmen verknüpft') }}</flux:text>
|
||||
@endforelse
|
||||
</div>
|
||||
</flux:card>
|
||||
@endif
|
||||
</div>
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
use Livewire\WithPagination; // Wichtig für Paginierung
|
||||
|
||||
|
||||
new class extends Component {
|
||||
new #[Layout('components.layouts.app'), Title('Benutzertabelle')] class extends Component {
|
||||
use WithPagination;
|
||||
|
||||
// Optional: Such- und Filter-Properties
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue