40 lines
1.2 KiB
PHP
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' => 'user',
|
|
'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,
|
|
]);
|
|
}
|
|
}
|