cyca/app/Console/Commands/UpdateFeeds.php
Richard Dern 400e3d01f1 Refresh
2022-01-12 00:35:37 +01:00

50 lines
933 B
PHP
Executable File

<?php
namespace App\Console\Commands;
use App\Jobs\EnqueueFeedUpdate;
use App\Models\Feed;
use Illuminate\Console\Command;
class UpdateFeeds extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'feed:update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Enqueue feeds that need update';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$oldest = now()->subMinute(config('cyca.maxAge.feed'));
$feeds = Feed::needingUpdate($oldest)->get();
foreach ($feeds as $feed) {
EnqueueFeedUpdate::dispatch($feed);
}
return 0;
}
}