Campaigns

Automations: when something happens, if conditions match, then run actions. Each runs once per customer per event.
New campaign
@foreach (['campaigns' => 'Campaigns', 'runs' => 'Run log'] as $k => $l)@endforeach
@if ($tab === 'campaigns')
CampaignWhenThenRunsLast runStatus @forelse ($campaigns as $c) {{ $c->name }}@if ($c->description){{ $c->description }}@endif {{ $triggers[$c->trigger][0] ?? $c->trigger }}@if (count((array) $c->conditions)){{ count((array) $c->conditions) }} {{ \Illuminate\Support\Str::plural('condition', count((array) $c->conditions)) }}@endif {{ collect($c->actions)->map(fn ($a) => \App\Services\Automation\CampaignEngine::action($a['type'] ?? '')?->label() ?? ($a['type'] ?? '?'))->implode(' → ') }} {{ number_format($c->runs_count) }}@if ($c->failed_count){{ $c->failed_count }} failed@endif {{ $c->last_run_at?->diffForHumans() ?? '—' }} {{ $c->isLive() ? 'Live' : ($c->is_active ? 'Scheduled' : 'Paused') }} @empty No campaigns yet. Example: when First purchase → create a 10% coupon → email it. @endforelse
@else
@foreach (['' => 'All', 'completed' => 'Completed', 'failed' => 'Failed'] as $k => $l)@endforeach
WhenCampaignEventCustomerResultStatus @forelse ($runs as $r) {{ $r->created_at->format('j M, H:i') }} {{ $r->campaign?->name }} {{ $r->event_key }} · {{ $r->event_ref }} @if ($r->user){{ $r->user->name }}@else Guest@endif {{ implode(' · ', (array) $r->results) }}@if ($r->error){{ $r->error }}@endif {{ ucfirst($r->status) }} @empty No runs yet. @endforelse
{{ $runs->links() }}
@endif