119 lines
5.1 KiB
PHP
119 lines
5.1 KiB
PHP
<?php
|
|
|
|
use App\Services\Customer\CustomerCompanyContext;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Volt\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
new #[Layout('components.layouts.app'), Title('Meine Firmen')] class extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public string $search = '';
|
|
|
|
public function updatedSearch(): void
|
|
{
|
|
$this->resetPage();
|
|
}
|
|
|
|
public function with(): array
|
|
{
|
|
$user = auth()->user();
|
|
$context = app(CustomerCompanyContext::class);
|
|
|
|
$pressKits = $context->accessibleCompanyQuery($user)
|
|
->withCount(['contacts', 'pressReleases'])
|
|
->when(filled($this->search), function ($query): void {
|
|
$search = trim($this->search);
|
|
|
|
$query->where(function ($query) use ($search): void {
|
|
$query->where('name', 'like', '%'.$search.'%')
|
|
->orWhere('email', 'like', '%'.$search.'%')
|
|
->orWhere('slug', 'like', '%'.$search.'%');
|
|
});
|
|
})
|
|
->orderBy('name')
|
|
->simplePaginate(24);
|
|
|
|
return [
|
|
'pressKits' => $pressKits,
|
|
'context' => $context,
|
|
'user' => $user,
|
|
];
|
|
}
|
|
}; ?>
|
|
|
|
<div class="space-y-6">
|
|
<flux:card>
|
|
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
|
<div>
|
|
<flux:heading size="lg">{{ __('Meine Firmen') }}</flux:heading>
|
|
<flux:subheading>{{ __('Verwalten Sie Firmen, Pressekontakte und zugeordnete Pressemitteilungen.') }}</flux:subheading>
|
|
</div>
|
|
<flux:button variant="primary" icon="plus" href="{{ route('me.profile') }}" wire:navigate>
|
|
{{ __('Firma anlegen anfragen') }}
|
|
</flux:button>
|
|
</div>
|
|
</flux:card>
|
|
|
|
<flux:card>
|
|
<flux:input wire:model.live.debounce.300ms="search" icon="magnifying-glass" placeholder="{{ __('Firma suchen...') }}" />
|
|
</flux:card>
|
|
|
|
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
|
@forelse($pressKits as $company)
|
|
<flux:card class="space-y-4">
|
|
<div class="flex items-start justify-between gap-3">
|
|
<div class="min-w-0">
|
|
<flux:heading size="sm" class="truncate">{{ $company->name }}</flux:heading>
|
|
<flux:text class="mt-1 text-xs text-zinc-500">{{ $company->slug }}</flux:text>
|
|
</div>
|
|
<flux:badge color="{{ $company->is_active ? 'green' : 'red' }}" size="sm">
|
|
{{ $company->is_active ? __('Aktiv') : __('Inaktiv') }}
|
|
</flux:badge>
|
|
</div>
|
|
|
|
<div class="flex flex-wrap gap-2">
|
|
<flux:badge color="zinc" size="sm">{{ $company->portal?->label() ?? __('Portal unbekannt') }}</flux:badge>
|
|
<flux:badge color="indigo" size="sm">{{ $context->roleLabelFor($company, $user) }}</flux:badge>
|
|
@if($company->disable_footer_code)
|
|
<flux:badge color="amber" size="sm">{{ __('Footer-Code aus') }}</flux:badge>
|
|
@endif
|
|
</div>
|
|
|
|
<div class="grid grid-cols-2 gap-3">
|
|
<div class="rounded-lg bg-zinc-50 p-3 dark:bg-zinc-900">
|
|
<flux:text class="text-xs text-zinc-500">{{ __('Pressemitteilungen') }}</flux:text>
|
|
<flux:text size="lg" weight="bold">{{ $company->press_releases_count }}</flux:text>
|
|
</div>
|
|
<div class="rounded-lg bg-zinc-50 p-3 dark:bg-zinc-900">
|
|
<flux:text class="text-xs text-zinc-500">{{ __('Pressekontakte') }}</flux:text>
|
|
<flux:text size="lg" weight="bold">{{ $company->contacts_count }}</flux:text>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-end">
|
|
<flux:button size="sm" variant="ghost" icon="arrow-right" href="{{ route('me.press-kits.show', $company->id) }}" wire:navigate>
|
|
{{ __('Firma öffnen') }}
|
|
</flux:button>
|
|
</div>
|
|
</flux:card>
|
|
@empty
|
|
<flux:card class="md:col-span-2 xl:col-span-3">
|
|
<div class="flex flex-col items-center justify-center py-10 text-center">
|
|
<flux:icon.building-office class="size-10 text-zinc-300" />
|
|
<flux:text weight="semibold" class="mt-3">{{ __('Keine Firmen gefunden') }}</flux:text>
|
|
<flux:text class="mt-1 max-w-md text-sm text-zinc-500">
|
|
{{ __('Prüfen Sie die Suche oder wenden Sie sich an den Support, wenn eine Firma fehlen sollte.') }}
|
|
</flux:text>
|
|
<flux:button class="mt-4" variant="primary" href="{{ route('me.profile') }}" wire:navigate>
|
|
{{ __('Profil prüfen') }}
|
|
</flux:button>
|
|
</div>
|
|
</flux:card>
|
|
@endforelse
|
|
</div>
|
|
|
|
{{ $pressKits->links() }}
|
|
</div>
|