<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use App\Jobs\CatalogScan as Job;
use App\Traits\Type;

class CatalogScan extends Command
{
	use Type;

	/**
	 * The name and signature of the console command.
	 *
	 * @var string
	 */
	protected $signature = 'catalog:scan'
		.' {type : Photo | Video }'
		.' {id : Photo ID}'
		.' {--dirty : Show Dirty}';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Scan Photo/Video for metadata';

	/**
	 * Execute the console command.
	 *
	 * @return mixed
	 */
	public function handle()
	{
		$class = $this->getModelType($this->argument('type'));

		$o = $class::findOrFail($this->argument('id'));

		return Job::dispatchSync($o,$this->option('dirty'));
	}
}