Files
kulakpos_web/Modules/MarketingAddon/App/Services/WhatsAppService.php

34 lines
827 B
PHP
Raw Normal View History

2026-05-14 11:55:22 +07:00
<?php
namespace Modules\MarketingAddon\App\Services;
use Modules\MarketingAddon\App\Models\Smsgateway;
class WhatsAppService
{
/**
* Send WhatsApp campaign via AiSensy
*/
public function send(
string $phone,
object $template,
int $businessId,
string $name,
array $data = [],
) {
$gateways = Smsgateway::where('channel', 'whatsapp')
->where('business_id', $businessId)
->where('status', 1)
->get();
if (empty($gateways)) {
throw new \Exception('No active WhatsApp gateway found for this business.');
}
foreach ($gateways as $gateway) {
$gateway->namespace::send_message($gateway, $phone, $template, $name, $data);
}
}
}