kithkin/app/Jobs/SyncSubscriptionsDispatcher.php

24 lines
624 B
PHP

<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Subscription;
class SyncSubscriptionsDispatcher implements ShouldQueue
{
use Dispatchable, Queueable, InteractsWithQueue, SerializesModels;
public function handle(): void
{
// fan-out: dispatch a SyncSubscription for every feed
Subscription::with('meta')
->cursor()
->each(fn ($sub) => SyncSubscription::dispatch($sub));
}
}