Start of console commands enhancements
This commit is contained in:
@@ -4,37 +4,38 @@ namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Traits\Type;
|
||||
|
||||
class CatalogScan extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'catalog:scan {type : Photo | Video } {id : Photo ID}';
|
||||
use Type;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Scan Photo for metadata';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'catalog:scan {type : Photo | Video } {id : Photo ID}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$class = 'App\Models\\'.$this->argument('type');
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Scan Photo for metadata';
|
||||
|
||||
if (! class_exists($class))
|
||||
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$class = $this->getModelType($this->argument('type'));
|
||||
|
||||
$o = $class::findOrFail($this->argument('id'));
|
||||
|
||||
if (! is_readable($o->file_path())) {
|
||||
if (! $o->isReadable()) {
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
return;
|
||||
}
|
||||
@@ -70,10 +71,10 @@ class CatalogScan extends Command
|
||||
$o->scanned = '1';
|
||||
|
||||
if ($o->getDirty()) {
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->filename));
|
||||
dump(['id'=>$o->id,'data'=>$o->getDirty()]);
|
||||
}
|
||||
|
||||
$o->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user