26 lines
632 B
PHP
26 lines
632 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Feed;
|
|
use App\Services\FeedFetcher;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
|
|
#[Signature('feeds:fetch')]
|
|
#[Description('Fetch feeds')]
|
|
class FetchFeeds extends Command
|
|
{
|
|
protected $signature = 'feeds:fetch';
|
|
|
|
public function handle(FeedFetcher $fetcher): void
|
|
{
|
|
Feed::query()->chunk(50, function ($feeds) use ($fetcher) {
|
|
foreach ($feeds as $feed) {
|
|
dispatch(fn () => $fetcher->fetch($feed))->onQueue('feeds');
|
|
}
|
|
});
|
|
}
|
|
}
|