2018-01-11 12:59:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
2019-11-09 03:58:15 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use App\Models\Photo;
|
2018-01-11 12:59:53 +00:00
|
|
|
use App\Jobs\CatalogScan;
|
|
|
|
|
|
|
|
class PhotoScanAll extends Command
|
|
|
|
{
|
|
|
|
use DispatchesJobs;
|
|
|
|
|
2019-11-09 03:58:15 +00:00
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'photo:scanall '.
|
|
|
|
'{--scanned : Rescan Scanned Photos}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-12-16 09:37:48 +00:00
|
|
|
protected $description = 'Scan Photos';
|
2019-11-09 03:58:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$o = ($this->option('scanned') ? Photo::NotRemove() : Photo::NotScanned());
|
|
|
|
|
|
|
|
$o->each(function ($item) {
|
|
|
|
if ($item->remove) {
|
|
|
|
Log::warning(sprintf('Not scanning [%s], marked for removal',$item->id));
|
|
|
|
return;
|
2018-01-11 12:59:53 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 03:58:15 +00:00
|
|
|
Log::info(sprintf('%s: Rescanning [%s]',__METHOD__,$item->id));
|
|
|
|
$this->dispatch((new CatalogScan($item))->onQueue('scan'));
|
|
|
|
});
|
|
|
|
|
|
|
|
Log::info(sprintf('Processed [%s]',$o->count()));
|
|
|
|
}
|
|
|
|
}
|