'', 'name' => '', 'description' => '', ]; public $file; public bool $isAllowed = false; public bool $canEdit = false; public ?int $confirmDeleteId = null; public function mount(): void { if (NostrAuth::check()) { $currentPubkey = NostrAuth::pubkey(); $currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $currentPubkey)->first(); if ( $currentPleb && $currentPleb->association_status->value > 1 && $currentPleb->paymentEvents()->where('year', date('Y'))->where('paid', true)->exists() ) { $this->isAllowed = true; } if ($currentPleb && in_array($currentPleb->npub, config('einundzwanzig.config.current_board'))) { $this->canEdit = true; } $this->loadNews(); } } #[Computed] public function filteredNews(): Collection|array { if ($this->selectedCategory === null) { return $this->news; } return collect($this->news)->filter( fn ($item) => $item->category->value === $this->selectedCategory ); } public function filterByCategory(?int $category): void { $this->selectedCategory = $this->selectedCategory === $category ? null : $category; } public function clearFilter(): void { $this->selectedCategory = null; } private function loadNews(): void { $this->news = Notification::query() ->with(['einundzwanzigPleb.profile']) ->latest() ->get(); } public function save(): void { $this->validate([ 'file' => 'required|file|mimes:pdf', 'form.category' => 'required|string|in:'.implode(',', NewsCategory::values()), 'form.name' => 'required|string|max:255', 'form.description' => 'nullable|string', ]); $currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', NostrAuth::pubkey())->first(); $news = Notification::query()->create([ 'name' => $this->form['name'], 'description' => $this->form['description'] ?? null, 'category' => $this->form['category'], 'einundzwanzig_pleb_id' => $currentPleb->id, ]); if ($this->file) { $news ->addMedia($this->file) ->toMediaCollection('pdf'); } $this->reset(['form', 'file']); $this->loadNews(); } public function confirmDelete(int $id): void { $this->confirmDeleteId = $id; } public function delete(): void { $news = Notification::query()->findOrFail($this->confirmDeleteId); $news->delete(); $this->loadNews(); } public function removeFile(): void { $this->file->delete(); $this->file = null; } }; ?>
{{ $post->description }}
Keine News in dieser Kategorie vorhanden.
Keine News vorhanden.
@endifUm die News einzusehen, benötigst du:
@if(!NostrAuth::check()) Bitte melde dich zunächst mit Nostr an. @else Bitte kontaktiere den Vorstand, wenn du denkst, dass du berechtigt sein solltest. @endif