2019-12-22 11:16:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
|
|
|
|
|
|
use App\Jobs\VideoMove;
|
|
|
|
|
|
|
|
class CatalogMove extends Command
|
|
|
|
{
|
|
|
|
use DispatchesJobs;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'catalog:move {type : Photo | Video }';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Trigger Moves';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$class = 'App\Models\\'.$this->argument('type');
|
|
|
|
|
|
|
|
if (! class_exists($class))
|
|
|
|
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
|
|
|
|
|
|
|
foreach ($class::where('filename','LIKE','%INCOMING%')->get() as $o) {
|
2019-12-26 04:56:31 +00:00
|
|
|
// Catch any files that are already there.
|
|
|
|
if ($o->moveable() === 1) {
|
|
|
|
$o->duplicate = TRUE;
|
|
|
|
$o->save();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $o->scanned OR $o->duplicate OR $o->remove OR ($x=$o->moveable()) !== TRUE) {
|
|
|
|
$this->warn(sprintf('Ignoring [%s]...',$o->file_path()));
|
2019-12-22 11:16:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (strtolower($this->argument('type'))) {
|
|
|
|
case 'video':
|
|
|
|
$this->dispatch((new VideoMove($o))->onQueue('move'));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|