first&last
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?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('Уведомления');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user