Files
einundzwanzig-verein/app/Livewire/EinundzwanzigFeed/Index.php
2026-01-17 23:26:05 +01:00

52 lines
1.0 KiB
PHP

<?php
namespace App\Livewire\EinundzwanzigFeed;
use App\Models\Event;
use Livewire\Component;
final class Index extends Component
{
public array $events = [];
public bool $newEvents = false;
public function mount(): void
{
$this->events = Event::query()
->where('type', 'root')
->orderBy('created_at', 'desc')
->with([
'renderedEvent',
])
->get()
->toArray();
}
public function hydrate(): void
{
if ($this->newEvents) {
$this->loadMore();
}
}
#[Rule('echo:events,.newEvents')]
public function updated(): void
{
$this->newEvents = true;
}
public function loadMore(): void
{
$this->newEvents = false;
$this->events = Event::query()
->where('type', 'root')
->orderBy('created_at', 'desc')
->with([
'renderedEvent',
])
->get()
->toArray();
}
}