Refactor SMS campaign handling to dispatch a job for starting campaigns and update notification messages for improved user feedback.
This commit is contained in:
38
app/Jobs/StartSmsCampaignJob.php
Normal file
38
app/Jobs/StartSmsCampaignJob.php
Normal 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user