You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

26 lines
599 B

<?php
use Illuminate\Database\Eloquent\Collection;
use Livewire\Attributes\Computed;
use Livewire\Component;
new class extends Component
{
#[Computed]
public function notifications(): Collection
{
return auth('web')->user()->unreadNotifications()->latest()->get();
}
public function read(string $id): void
{
$this->notifications->where('id', $id)->first()?->markAsRead();
$this->__unset('notifications');
}
public function readAll(): void
{
$this->notifications->markAsRead();
$this->__unset('notifications');
}
};