richard
/
cyca
Archived
1
0
Fork 0
This repository has been archived on 2024-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
cyca/app/Console/Commands/UpdateDocuments.php

50 lines
983 B
PHP
Executable File

<?php
namespace App\Console\Commands;
use App\Jobs\EnqueueDocumentUpdate;
use App\Models\Document;
use Illuminate\Console\Command;
class UpdateDocuments extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'document:update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Enqueue documents 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.document'));
$documents = Document::needingUpdate($oldest)->get();
foreach ($documents as $document) {
EnqueueDocumentUpdate::dispatch($document);
}
return 0;
}
}