Initial PHP rebuild of the app
This commit is contained in:
690 files changed
+33944
-12046
No files matched your search
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Notifications;
|
||||
|
||||
use App\Enums\{NotificationChannel, NotificationType};
|
||||
use App\Models\{Business, Notification};
|
||||
|
||||
class NotificationService
|
||||
{
|
||||
public function create(Business $business, NotificationType $type, string $body, string $idempotencyKey, ?string $userId = null, ?string $customerId = null, ?string $appointmentId = null, ?string $deepLinkPath = null, ?string $subject = null): Notification
|
||||
{
|
||||
$notification = Notification::query()->firstOrCreate(
|
||||
['idempotencyKey' => $idempotencyKey],
|
||||
['businessId' => $business->id, 'recipientUserId' => $userId, 'recipientCustomerId' => $customerId, 'type' => $type, 'appointmentId' => $appointmentId, 'subject' => $subject, 'bodyText' => $body, 'deepLinkPath' => $deepLinkPath],
|
||||
);
|
||||
if ($userId) $notification->deliveries()->firstOrCreate(['channel' => NotificationChannel::InApp], ['status' => 'SENT', 'sentAt' => now()]);
|
||||
return $notification;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user