mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-21 01:50:15 +00:00
🚀 Add courses and lecturers management functionality
This commit is contained in:
202
resources/views/livewire/lecturers/create.blade.php
Normal file
202
resources/views/livewire/lecturers/create.blade.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Lecturer;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Volt\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
new class extends Component {
|
||||
use WithFileUploads;
|
||||
|
||||
#[Validate('image|max:10240')] // 10MB Max
|
||||
public $avatar;
|
||||
|
||||
public string $name = '';
|
||||
public ?string $subtitle = null;
|
||||
public ?string $intro = null;
|
||||
public ?string $description = null;
|
||||
public bool $active = true;
|
||||
|
||||
// Social & Payment Links
|
||||
public ?string $website = null;
|
||||
public ?string $twitter_username = null;
|
||||
public ?string $nostr = null;
|
||||
public ?string $lightning_address = null;
|
||||
public ?string $lnurl = null;
|
||||
public ?string $node_id = null;
|
||||
public ?string $paynym = null;
|
||||
|
||||
public function createLecturer(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'name' => ['required', 'string', 'max:255', 'unique:lecturers,name'],
|
||||
'subtitle' => ['nullable', 'string'],
|
||||
'intro' => ['nullable', 'string'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'active' => ['boolean'],
|
||||
'website' => ['nullable', 'url', 'max:255'],
|
||||
'twitter_username' => ['nullable', 'string', 'max:255'],
|
||||
'nostr' => ['nullable', 'string', 'max:255'],
|
||||
'lightning_address' => ['nullable', 'string'],
|
||||
'lnurl' => ['nullable', 'string'],
|
||||
'node_id' => ['nullable', 'string', 'max:255'],
|
||||
'paynym' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$lecturer = Lecturer::create($validated);
|
||||
|
||||
if ($this->avatar) {
|
||||
$lecturer
|
||||
->addMedia($this->avatar->getRealPath())
|
||||
->usingName($lecturer->name)
|
||||
->toMediaCollection('avatar');
|
||||
}
|
||||
|
||||
session()->flash('status', __('Dozent erfolgreich erstellt!'));
|
||||
|
||||
$this->redirect(route_with_country('lecturers.edit', ['lecturer' => $lecturer]), navigate: true);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="max-w-4xl mx-auto p-6">
|
||||
<flux:heading size="xl" class="mb-8">{{ __('Neuen Dozenten erstellen') }}</flux:heading>
|
||||
|
||||
<form wire:submit="createLecturer" class="space-y-10">
|
||||
|
||||
<!-- Basic Information -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Grundlegende Informationen') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
|
||||
<flux:file-upload wire:model="avatar">
|
||||
<!-- Custom avatar uploader -->
|
||||
<div class="
|
||||
relative flex items-center justify-center size-20 rounded-full transition-colors cursor-pointer
|
||||
border border-zinc-200 dark:border-white/10 hover:border-zinc-300 dark:hover:border-white/10
|
||||
bg-zinc-100 hover:bg-zinc-200 dark:bg-white/10 hover:dark:bg-white/15 in-data-dragging:dark:bg-white/15
|
||||
">
|
||||
@if($avatar)
|
||||
<img src="{{ $avatar?->temporaryUrl() }}" alt="Avatar"
|
||||
class="size-full object-cover rounded-full"/>
|
||||
@else
|
||||
<flux:icon name="user" variant="solid" class="text-zinc-500 dark:text-zinc-400"/>
|
||||
@endif
|
||||
|
||||
<div class="absolute bottom-0 right-0 bg-white dark:bg-zinc-800 rounded-full">
|
||||
<flux:icon name="arrow-up-circle" variant="solid" class="text-zinc-500 dark:text-zinc-400"/>
|
||||
</div>
|
||||
</div>
|
||||
</flux:file-upload>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Name') }} <span class="text-red-500">*</span></flux:label>
|
||||
<flux:input wire:model="name" required/>
|
||||
<flux:description>{{ __('Vollständiger Name des Dozenten') }}</flux:description>
|
||||
<flux:error name="name"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Untertitel') }}</flux:label>
|
||||
<flux:input wire:model="subtitle"/>
|
||||
<flux:description>{{ __('Kurze Berufsbezeichnung oder Rolle') }}</flux:description>
|
||||
<flux:error name="subtitle"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Status') }}</flux:label>
|
||||
<flux:switch wire:model="active"/>
|
||||
<flux:description>{{ __('Ist dieser Dozent aktiv?') }}</flux:description>
|
||||
</flux:field>
|
||||
</div>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Einführung') }}</flux:label>
|
||||
<flux:textarea wire:model="intro" rows="3"/>
|
||||
<flux:description>{{ __('Kurze Vorstellung (wird auf Kurs-Seiten angezeigt)') }}</flux:description>
|
||||
<flux:error name="intro"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Beschreibung') }}</flux:label>
|
||||
<flux:textarea wire:model="description" rows="6"/>
|
||||
<flux:description>{{ __('Ausführliche Beschreibung und Biografie') }}</flux:description>
|
||||
<flux:error name="description"/>
|
||||
</flux:field>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- Social Links -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Links & Soziale Medien') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Webseite') }}</flux:label>
|
||||
<flux:input wire:model="website" type="url" placeholder="https://example.com"/>
|
||||
<flux:description>{{ __('Persönliche Webseite oder Portfolio') }}</flux:description>
|
||||
<flux:error name="website"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Twitter Benutzername') }}</flux:label>
|
||||
<flux:input wire:model="twitter_username" placeholder="benutzername"/>
|
||||
<flux:description>{{ __('Twitter-Handle ohne @ Symbol') }}</flux:description>
|
||||
<flux:error name="twitter_username"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Nostr') }}</flux:label>
|
||||
<flux:input wire:model="nostr" placeholder="npub..."/>
|
||||
<flux:description>{{ __('Nostr öffentlicher Schlüssel') }}</flux:description>
|
||||
<flux:error name="nostr"/>
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- Payment Information -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Zahlungsinformationen') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Lightning Adresse') }}</flux:label>
|
||||
<flux:input wire:model="lightning_address" placeholder="name@getalby.com"/>
|
||||
<flux:description>{{ __('Lightning-Adresse für Zahlungen') }}</flux:description>
|
||||
<flux:error name="lightning_address"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('LNURL') }}</flux:label>
|
||||
<flux:input wire:model="lnurl"/>
|
||||
<flux:description>{{ __('LNURL für Lightning-Zahlungen') }}</flux:description>
|
||||
<flux:error name="lnurl"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Node ID') }}</flux:label>
|
||||
<flux:input wire:model="node_id"/>
|
||||
<flux:description>{{ __('Lightning Node ID') }}</flux:description>
|
||||
<flux:error name="node_id"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('PayNym') }}</flux:label>
|
||||
<flux:input wire:model="paynym"/>
|
||||
<flux:description>{{ __('PayNym für Bitcoin-Zahlungen') }}</flux:description>
|
||||
<flux:error name="paynym"/>
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="flex items-center justify-between pt-8 border-t border-gray-200 dark:border-gray-700">
|
||||
<flux:button class="cursor-pointer" variant="ghost" type="button" onclick="history.back()">
|
||||
{{ __('Abbrechen') }}
|
||||
</flux:button>
|
||||
|
||||
<flux:button class="cursor-pointer" variant="primary" type="submit">
|
||||
{{ __('Dozenten erstellen') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
278
resources/views/livewire/lecturers/edit.blade.php
Normal file
278
resources/views/livewire/lecturers/edit.blade.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Lecturer;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Volt\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
new class extends Component {
|
||||
use WithFileUploads;
|
||||
|
||||
#[Validate('image|max:10240')] // 10MB Max
|
||||
public $avatar;
|
||||
|
||||
public Lecturer $lecturer;
|
||||
|
||||
public string $name = '';
|
||||
public ?string $subtitle = null;
|
||||
public ?string $intro = null;
|
||||
public ?string $description = null;
|
||||
public bool $active = true;
|
||||
|
||||
// Social & Payment Links
|
||||
public ?string $website = null;
|
||||
public ?string $twitter_username = null;
|
||||
public ?string $nostr = null;
|
||||
public ?string $lightning_address = null;
|
||||
public ?string $lnurl = null;
|
||||
public ?string $node_id = null;
|
||||
public ?string $paynym = null;
|
||||
|
||||
// System fields (read-only)
|
||||
public ?int $created_by = null;
|
||||
public ?string $created_at = null;
|
||||
public ?string $updated_at = null;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->lecturer->load('media');
|
||||
|
||||
$this->name = $this->lecturer->name ?? '';
|
||||
$this->subtitle = $this->lecturer->subtitle;
|
||||
$this->intro = $this->lecturer->intro;
|
||||
$this->description = $this->lecturer->description;
|
||||
$this->active = (bool) $this->lecturer->active;
|
||||
|
||||
$this->website = $this->lecturer->website;
|
||||
$this->twitter_username = $this->lecturer->twitter_username;
|
||||
$this->nostr = $this->lecturer->nostr;
|
||||
$this->lightning_address = $this->lecturer->lightning_address;
|
||||
$this->lnurl = $this->lecturer->lnurl;
|
||||
$this->node_id = $this->lecturer->node_id;
|
||||
$this->paynym = $this->lecturer->paynym;
|
||||
|
||||
$this->created_by = $this->lecturer->created_by;
|
||||
$this->created_at = $this->lecturer->created_at?->format('Y-m-d H:i:s');
|
||||
$this->updated_at = $this->lecturer->updated_at?->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function updateLecturer(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'name' => ['required', 'string', 'max:255', Rule::unique('lecturers')->ignore($this->lecturer->id)],
|
||||
'subtitle' => ['nullable', 'string'],
|
||||
'intro' => ['nullable', 'string'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'active' => ['boolean'],
|
||||
'website' => ['nullable', 'url', 'max:255'],
|
||||
'twitter_username' => ['nullable', 'string', 'max:255'],
|
||||
'nostr' => ['nullable', 'string', 'max:255'],
|
||||
'lightning_address' => ['nullable', 'string'],
|
||||
'lnurl' => ['nullable', 'string'],
|
||||
'node_id' => ['nullable', 'string', 'max:255'],
|
||||
'paynym' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$this->lecturer->update($validated);
|
||||
|
||||
if ($this->avatar) {
|
||||
$this->lecturer->clearMediaCollection('avatar');
|
||||
$this->lecturer
|
||||
->addMedia($this->avatar->getRealPath())
|
||||
->usingName($this->lecturer->name)
|
||||
->toMediaCollection('avatar');
|
||||
$this->avatar = null;
|
||||
$this->lecturer->load('media');
|
||||
}
|
||||
|
||||
$this->dispatch('lecturer-updated', name: $this->lecturer->name);
|
||||
|
||||
session()->flash('status', __('Dozent erfolgreich aktualisiert!'));
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="max-w-4xl mx-auto p-6">
|
||||
<flux:heading size="xl" class="mb-8">{{ __('Dozent bearbeiten') }}: {{ $lecturer->name }}</flux:heading>
|
||||
|
||||
<form wire:submit="updateLecturer" class="space-y-10">
|
||||
|
||||
<!-- Basic Information -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Grundlegende Informationen') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
|
||||
<flux:file-upload wire:model="avatar">
|
||||
<!-- Custom avatar uploader -->
|
||||
<div class="
|
||||
relative flex items-center justify-center size-20 rounded-full transition-colors cursor-pointer
|
||||
border border-zinc-200 dark:border-white/10 hover:border-zinc-300 dark:hover:border-white/10
|
||||
bg-zinc-100 hover:bg-zinc-200 dark:bg-white/10 hover:dark:bg-white/15 in-data-dragging:dark:bg-white/15
|
||||
">
|
||||
@if (!$avatar && $lecturer->getFirstMedia('avatar'))
|
||||
<img src="{{ $lecturer->getFirstMediaUrl('avatar') }}" alt="Avatar"
|
||||
class="size-full object-cover rounded-full"/>
|
||||
@elseif($avatar)
|
||||
<img src="{{ $avatar?->temporaryUrl() }}" alt="Avatar"
|
||||
class="size-full object-cover rounded-full"/>
|
||||
@else
|
||||
<flux:icon name="user" variant="solid" class="text-zinc-500 dark:text-zinc-400"/>
|
||||
@endif
|
||||
|
||||
<div class="absolute bottom-0 right-0 bg-white dark:bg-zinc-800 rounded-full">
|
||||
<flux:icon name="arrow-up-circle" variant="solid" class="text-zinc-500 dark:text-zinc-400"/>
|
||||
</div>
|
||||
</div>
|
||||
</flux:file-upload>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('ID') }}</flux:label>
|
||||
<flux:input value="{{ $lecturer->id }}" disabled/>
|
||||
<flux:description>{{ __('System-generierte ID (nur lesbar)') }}</flux:description>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Name') }} <span class="text-red-500">*</span></flux:label>
|
||||
<flux:input wire:model="name" required/>
|
||||
<flux:description>{{ __('Vollständiger Name des Dozenten') }}</flux:description>
|
||||
<flux:error name="name"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Untertitel') }}</flux:label>
|
||||
<flux:input wire:model="subtitle"/>
|
||||
<flux:description>{{ __('Kurze Berufsbezeichnung oder Rolle') }}</flux:description>
|
||||
<flux:error name="subtitle"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Status') }}</flux:label>
|
||||
<flux:switch wire:model="active"/>
|
||||
<flux:description>{{ __('Ist dieser Dozent aktiv?') }}</flux:description>
|
||||
</flux:field>
|
||||
</div>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Einführung') }}</flux:label>
|
||||
<flux:textarea wire:model="intro" rows="3"/>
|
||||
<flux:description>{{ __('Kurze Vorstellung (wird auf Kurs-Seiten angezeigt)') }}</flux:description>
|
||||
<flux:error name="intro"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Beschreibung') }}</flux:label>
|
||||
<flux:textarea wire:model="description" rows="6"/>
|
||||
<flux:description>{{ __('Ausführliche Beschreibung und Biografie') }}</flux:description>
|
||||
<flux:error name="description"/>
|
||||
</flux:field>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- Social Links -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Links & Soziale Medien') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Webseite') }}</flux:label>
|
||||
<flux:input wire:model="website" type="url" placeholder="https://example.com"/>
|
||||
<flux:description>{{ __('Persönliche Webseite oder Portfolio') }}</flux:description>
|
||||
<flux:error name="website"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Twitter Benutzername') }}</flux:label>
|
||||
<flux:input wire:model="twitter_username" placeholder="benutzername"/>
|
||||
<flux:description>{{ __('Twitter-Handle ohne @ Symbol') }}</flux:description>
|
||||
<flux:error name="twitter_username"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Nostr') }}</flux:label>
|
||||
<flux:input wire:model="nostr" placeholder="npub..."/>
|
||||
<flux:description>{{ __('Nostr öffentlicher Schlüssel') }}</flux:description>
|
||||
<flux:error name="nostr"/>
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- Payment Information -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Zahlungsinformationen') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Lightning Adresse') }}</flux:label>
|
||||
<flux:input wire:model="lightning_address" placeholder="name@getalby.com"/>
|
||||
<flux:description>{{ __('Lightning-Adresse für Zahlungen') }}</flux:description>
|
||||
<flux:error name="lightning_address"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('LNURL') }}</flux:label>
|
||||
<flux:input wire:model="lnurl"/>
|
||||
<flux:description>{{ __('LNURL für Lightning-Zahlungen') }}</flux:description>
|
||||
<flux:error name="lnurl"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Node ID') }}</flux:label>
|
||||
<flux:input wire:model="node_id"/>
|
||||
<flux:description>{{ __('Lightning Node ID') }}</flux:description>
|
||||
<flux:error name="node_id"/>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('PayNym') }}</flux:label>
|
||||
<flux:input wire:model="paynym"/>
|
||||
<flux:description>{{ __('PayNym für Bitcoin-Zahlungen') }}</flux:description>
|
||||
<flux:error name="paynym"/>
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- System Information -->
|
||||
<flux:fieldset class="space-y-6">
|
||||
<flux:legend>{{ __('Systeminformationen') }}</flux:legend>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Erstellt von') }}</flux:label>
|
||||
<flux:input value="{{ $lecturer->createdBy?->name ?? __('Unbekannt') }}" disabled/>
|
||||
<flux:description>{{ __('Ersteller des Dozenten') }}</flux:description>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Erstellt am') }}</flux:label>
|
||||
<flux:input value="{{ $created_at }}" disabled/>
|
||||
<flux:description>{{ __('Wann dieser Dozent erstellt wurde') }}</flux:description>
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Aktualisiert am') }}</flux:label>
|
||||
<flux:input value="{{ $updated_at }}" disabled/>
|
||||
<flux:description>{{ __('Letzte Änderungszeit') }}</flux:description>
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:fieldset>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="flex items-center justify-between pt-8 border-t border-gray-200 dark:border-gray-700">
|
||||
<flux:button class="cursor-pointer" variant="ghost" type="button" onclick="history.back()">
|
||||
{{ __('Abbrechen') }}
|
||||
</flux:button>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
@if (session('status'))
|
||||
<flux:text class="text-green-600 dark:text-green-400 font-medium">
|
||||
{{ session('status') }}
|
||||
</flux:text>
|
||||
@endif
|
||||
|
||||
<flux:button class="cursor-pointer" variant="primary" type="submit">
|
||||
{{ __('Dozent aktualisieren') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
136
resources/views/livewire/lecturers/index.blade.php
Normal file
136
resources/views/livewire/lecturers/index.blade.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Lecturer;
|
||||
use Livewire\Volt\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
new class extends Component {
|
||||
use WithPagination;
|
||||
|
||||
public $country = 'de';
|
||||
public $sortBy = 'name';
|
||||
public $sortDirection = 'asc';
|
||||
public $search = '';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->country = request()->route('country');
|
||||
}
|
||||
|
||||
public function sort($column)
|
||||
{
|
||||
if ($this->sortBy === $column) {
|
||||
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
$this->sortBy = $column;
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
return [
|
||||
'lecturers' => Lecturer::with(['createdBy'])
|
||||
->when($this->search, fn($query)
|
||||
=> $query->where('name', 'ilike', '%'.$this->search.'%')
|
||||
->orWhere('description', 'ilike', '%'.$this->search.'%')
|
||||
->orWhere('subtitle', 'ilike', '%'.$this->search.'%'),
|
||||
)
|
||||
->orderBy($this->sortBy, $this->sortDirection)
|
||||
->paginate(15),
|
||||
];
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<flux:heading size="xl">{{ __('Dozenten') }}</flux:heading>
|
||||
<div class="flex items-center gap-4">
|
||||
<flux:input
|
||||
wire:model.live="search"
|
||||
:placeholder="__('Suche nach Dozenten...')"
|
||||
clearable
|
||||
/>
|
||||
@auth
|
||||
<flux:button class="cursor-pointer" :href="route_with_country('lecturers.create')" icon="plus" variant="primary">
|
||||
{{ __('Dozenten anlegen') }}
|
||||
</flux:button>
|
||||
@endauth
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<flux:table :paginate="$lecturers" class="mt-6">
|
||||
<flux:table.columns>
|
||||
<flux:table.column sortable :sorted="$sortBy === 'name'" :direction="$sortDirection"
|
||||
wire:click="sort('name')">{{ __('Name') }}
|
||||
</flux:table.column>
|
||||
<flux:table.column>{{ __('Untertitel') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Kurse') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Links') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Aktionen') }}</flux:table.column>
|
||||
</flux:table.columns>
|
||||
|
||||
<flux:table.rows>
|
||||
@foreach ($lecturers as $lecturer)
|
||||
<flux:table.row :key="$lecturer->id">
|
||||
<flux:table.cell variant="strong" class="flex items-center gap-3">
|
||||
<flux:avatar size="lg" src="{{ $lecturer->getFirstMedia('avatar') ? $lecturer->getFirstMediaUrl('avatar', 'thumb') : asset('img/einundzwanzig.png') }}"/>
|
||||
<div>
|
||||
<div class="font-semibold">{{ $lecturer->name }}</div>
|
||||
@if($lecturer->active)
|
||||
<flux:badge size="sm" color="green">{{ __('Aktiv') }}</flux:badge>
|
||||
@else
|
||||
<flux:badge size="sm" color="zinc">{{ __('Inaktiv') }}</flux:badge>
|
||||
@endif
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
@if($lecturer->subtitle)
|
||||
<div class="text-sm text-zinc-600 dark:text-zinc-400">
|
||||
{{ Str::limit($lecturer->subtitle, 50) }}
|
||||
</div>
|
||||
@endif
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:badge size="sm">{{ $lecturer->courses()->count() }} {{ __('Kurse') }}</flux:badge>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<div class="flex gap-2">
|
||||
@if($lecturer->website)
|
||||
<flux:link :href="$lecturer->website" external variant="subtle" title="{{ __('Website') }}">
|
||||
<flux:icon.globe-alt variant="mini"/>
|
||||
</flux:link>
|
||||
@endif
|
||||
@if($lecturer->twitter_username)
|
||||
<flux:link :href="'https://twitter.com/' . $lecturer->twitter_username" external
|
||||
variant="subtle" title="{{ __('Twitter') }}">
|
||||
<flux:icon.x-mark variant="mini"/>
|
||||
</flux:link>
|
||||
@endif
|
||||
@if($lecturer->nostr)
|
||||
<flux:link :href="'https://njump.me/'.$lecturer->nostr" external variant="subtle"
|
||||
title="{{ __('Nostr') }}">
|
||||
<flux:icon.bolt variant="mini"/>
|
||||
</flux:link>
|
||||
@endif
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:button
|
||||
:disabled="$lecturer->created_by !== auth()->id()"
|
||||
:href="$lecturer->created_by === auth()->id() ? route_with_country('lecturers.edit', ['lecturer' => $lecturer]) : null"
|
||||
size="xs"
|
||||
variant="filled"
|
||||
icon="pencil">
|
||||
{{ __('Bearbeiten') }}
|
||||
</flux:button>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@endforeach
|
||||
</flux:table.rows>
|
||||
</flux:table>
|
||||
</div>
|
||||
Reference in New Issue
Block a user