29 lines
879 B
PHP
29 lines
879 B
PHP
<?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;
|
|
}
|
|
}
|