Refactor SMS campaign handling to dispatch a job for starting campaigns and update notification messages for improved user feedback.

This commit is contained in:
Mekan1206
2026-06-04 19:03:15 +05:00
parent 8e66883587
commit 21feb3baa6
4 changed files with 112 additions and 49 deletions

View File

@@ -0,0 +1,38 @@
<?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,
);
}
}