Initial Ladill Frontdesk release with deploy pipeline.
Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Campaign;
|
||||
use App\Models\CampaignRecipient;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class DispatchCampaignJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(public int $campaignId)
|
||||
{
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$campaign = Campaign::query()->find($this->campaignId);
|
||||
|
||||
if (! $campaign || ! in_array($campaign->status, [Campaign::STATUS_QUEUED, Campaign::STATUS_SENDING], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($campaign->recipient_count === 0) {
|
||||
$campaign->forceFill([
|
||||
'status' => Campaign::STATUS_FAILED,
|
||||
'completed_at' => now(),
|
||||
])->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$campaign->forceFill(['status' => Campaign::STATUS_SENDING])->save();
|
||||
|
||||
$campaign->recipients()
|
||||
->where('status', CampaignRecipient::STATUS_PENDING)
|
||||
->orderBy('id')
|
||||
->pluck('id')
|
||||
->each(fn (int $recipientId) => SendCampaignMessageJob::dispatch($recipientId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user