38 lines
958 B
PHP
38 lines
958 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Notifications;
|
|
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
#[Layout('layouts.app')]
|
|
class NotificationsPage extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public function markAllAsRead(): void
|
|
{
|
|
auth()->user()?->unreadNotifications->markAsRead();
|
|
session()->flash('success', 'Все уведомления помечены как прочитанные.');
|
|
}
|
|
|
|
public function markAsRead(string $id): void
|
|
{
|
|
$notification = auth()->user()?->notifications()->findOrFail($id);
|
|
$notification->markAsRead();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
$notifications = auth()->user()
|
|
?->notifications()
|
|
->latest()
|
|
->paginate(15);
|
|
|
|
return view('livewire.notifications.notifications-page', [
|
|
'notifications' => $notifications,
|
|
])->title('Уведомления');
|
|
}
|
|
}
|