update marketing
All checks were successful
All checks were successful
This commit is contained in:
33
Modules/MarketingAddon/App/Services/WhatsAppService.php
Normal file
33
Modules/MarketingAddon/App/Services/WhatsAppService.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user