enabled() ->where('project_id', $event->payload->projectId) ->where('event_type', $event->payload->eventType->value) ->get(['channel', 'id']) ->each(function (NotificationAction $notificationAction) use ($event): void { $notificationDeliveryLogId = null; if (in_array($notificationAction->channel, [NotificationChannel::Discord, NotificationChannel::Webhook], true)) { $notificationDeliveryLogId = NotificationDeliveryLog::query()->create([ 'attempt_count' => 0, 'channel' => $notificationAction->channel, 'delivery_status' => NotificationDeliveryStatus::Pending, 'event_type' => $event->payload->eventType, 'notification_action_id' => $notificationAction->id, 'payload_metadata' => [ 'project_key' => $event->payload->projectKey, 'ticket_key' => $event->payload->ticketKey, ], ])->id; } DeliverNotificationAction::dispatch( notificationActionId: $notificationAction->id, payload: $event->payload, notificationDeliveryLogId: $notificationDeliveryLogId, ); }); } }