add notifications logic and add support of both JWT and Sanctum
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Notifications;
|
||||
|
||||
use App\Models\UserNotification;
|
||||
|
||||
class NotificationReadService
|
||||
{
|
||||
public function markRead(int $userId, int $notificationId): bool
|
||||
{
|
||||
$row = UserNotification::query()
|
||||
->where('user_id', $userId)
|
||||
->where('notification_id', $notificationId)
|
||||
->first();
|
||||
|
||||
if (!$row) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$row->is_read = true;
|
||||
$row->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user