Files
alrahma_sunday_school_api/app/Services/Payments/PaymentNotificationDispatchService.php
T
2026-06-09 02:32:58 -04:00

40 lines
1.2 KiB
PHP

<?php
namespace App\Services\Payments;
use App\Models\Notification;
use App\Models\UserNotification;
use App\Models\Configuration;
class PaymentNotificationDispatchService
{
public function notifyUser(int $userId, string $title, string $message, array $channels = ['in_app']): void
{
$schoolYear = Configuration::getConfig('school_year');
$semester = Configuration::getConfig('semester');
$notification = Notification::query()->create([
'title' => $title,
'message' => $message,
'target_group' => 'everyone',
'delivery_channels' => $channels,
'priority' => 'normal',
'status' => 'sent',
'scheduled_at' => now(),
'sent_at' => now(),
'school_year' => $schoolYear,
'semester' => $semester,
]);
UserNotification::query()->create([
'notification_id' => (int) $notification->id,
'user_id' => $userId,
'is_read' => 0,
'delivered' => 1,
'delivered_at' => now(),
'school_year' => $schoolYear,
'semester' => $semester,
]);
}
}