39 lines
959 B
PHP
39 lines
959 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\User;
|
|
use App\Services\SmsBroadcastService;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
|
|
class StartSmsCampaignJob implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* @param array<int, int|string> $selectedIds
|
|
* @param array<int, int|string> $excludedIds
|
|
*/
|
|
public function __construct(
|
|
public int $adminId,
|
|
public string $message,
|
|
public bool $sendToAll,
|
|
public array $selectedIds = [],
|
|
public array $excludedIds = [],
|
|
) {}
|
|
|
|
public function handle(SmsBroadcastService $service): void
|
|
{
|
|
$admin = User::query()->findOrFail($this->adminId);
|
|
|
|
$service->startCampaign(
|
|
admin: $admin,
|
|
message: $this->message,
|
|
sendToAll: $this->sendToAll,
|
|
selectedIds: $this->selectedIds,
|
|
excludedIds: $this->excludedIds,
|
|
);
|
|
}
|
|
}
|