34 lines
827 B
PHP
34 lines
827 B
PHP
|
|
<?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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|