add notifications logic and add support of both JWT and Sanctum
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Notifications;
|
||||
|
||||
use App\Models\UserNotification;
|
||||
|
||||
class NotificationShowService
|
||||
{
|
||||
public function getForUser(int $userId, int $notificationId): ?array
|
||||
{
|
||||
$row = UserNotification::query()
|
||||
->select([
|
||||
'user_notifications.*',
|
||||
'notifications.title',
|
||||
'notifications.message',
|
||||
'notifications.priority',
|
||||
'notifications.scheduled_at',
|
||||
'notifications.expires_at',
|
||||
'notifications.target_group',
|
||||
])
|
||||
->join('notifications', 'notifications.id', '=', 'user_notifications.notification_id')
|
||||
->where('user_notifications.user_id', $userId)
|
||||
->where('user_notifications.notification_id', $notificationId)
|
||||
->first();
|
||||
|
||||
return $row ? $row->toArray() : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user