Major refactor of photo processing, video processing still to do
This commit is contained in:
parent
2d04c8ccbb
commit
9208ddf779
35
app/Casts/PostgresBytea.php
Normal file
35
app/Casts/PostgresBytea.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PostgresBytea implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Cast the given value.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
public function get(Model $model, string $key, mixed $value, array $attributes): mixed
|
||||||
|
{
|
||||||
|
// For stream resources, we need to fseek in case we've already read it.
|
||||||
|
if (is_resource($value)) {
|
||||||
|
rewind($value);
|
||||||
|
$value = stream_get_contents($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hex2bin($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the given value for storage.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
|
||||||
|
{
|
||||||
|
return bin2hex($value);
|
||||||
|
}
|
||||||
|
}
|
@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
use App\Traits\Type;
|
|
||||||
|
|
||||||
class CatalogDump extends Command
|
|
||||||
{
|
|
||||||
use Type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'catalog:dump {type : Photo | Video } {id : Photo ID}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Scan Photo for metadata';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$class = $this->getModelType($this->argument('type'));
|
|
||||||
|
|
||||||
$o = $class::findOrFail($this->argument('id'));
|
|
||||||
|
|
||||||
if (! $o->isReadable()) {
|
|
||||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
dump($o->properties());
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Jobs\CatalogScan as Job;
|
||||||
use App\Traits\Type;
|
use App\Traits\Type;
|
||||||
|
|
||||||
class CatalogScan extends Command
|
class CatalogScan extends Command
|
||||||
@ -25,7 +26,7 @@ class CatalogScan extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Scan Photo for metadata';
|
protected $description = 'Scan Photo/Video for metadata';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
@ -38,54 +39,6 @@ class CatalogScan extends Command
|
|||||||
|
|
||||||
$o = $class::findOrFail($this->argument('id'));
|
$o = $class::findOrFail($this->argument('id'));
|
||||||
|
|
||||||
if (! $o->isReadable()) {
|
return Job::dispatchSync($o);
|
||||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$o->setDateCreated();
|
|
||||||
$o->setSubSecTime();
|
|
||||||
$o->setSignature();
|
|
||||||
$o->setMakeModel();
|
|
||||||
$o->setLocation();
|
|
||||||
$o->setHeightWidth();
|
|
||||||
$o->setThumbnail();
|
|
||||||
|
|
||||||
// If this is a duplicate
|
|
||||||
$x = $o->myduplicates()->get();
|
|
||||||
if (count($x)) {
|
|
||||||
foreach ($x as $oo) {
|
|
||||||
// And that photo is not marked as a duplicate
|
|
||||||
if (! $oo->duplicate) {
|
|
||||||
$o->duplicate = '1';
|
|
||||||
$this->warn(sprintf('Image [%s] marked as a duplicate',$o->filename));
|
|
||||||
|
|
||||||
// If the file signature also matches, we'll mark it for deletion
|
|
||||||
if ($oo->file_signature AND $o->file_signature == $oo->file_signature) {
|
|
||||||
$this->warn(sprintf('Image [%s] marked for deletion',$o->filename));
|
|
||||||
$o->remove = '1';
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$o->scanned = '1';
|
|
||||||
|
|
||||||
if ($o->getDirty()) {
|
|
||||||
$this->warn(sprintf('Image [%s] metadata changed',$o->filename));
|
|
||||||
|
|
||||||
if ($this->option('dirty'))
|
|
||||||
dump(['id'=>$o->id,'data'=>$o->getDirty()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the file signature changed, abort the update.
|
|
||||||
if ($o->getOriginal('file_signature') AND $o->wasChanged('file_signature')) {
|
|
||||||
dump(['old'=>$o->getOriginal('file_signature'),'new'=>$o->file_signature]);
|
|
||||||
abort(500,'File Signature Changed?');
|
|
||||||
}
|
|
||||||
|
|
||||||
$o->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
use App\Jobs\CatalogScan;
|
use App\Jobs\CatalogScan;
|
||||||
use App\Traits\Type;
|
use App\Traits\Type;
|
||||||
@ -13,14 +16,18 @@ class CatalogScanAll extends Command
|
|||||||
{
|
{
|
||||||
use DispatchesJobs,Type;
|
use DispatchesJobs,Type;
|
||||||
|
|
||||||
|
private int|bool $depth = true;
|
||||||
|
protected const chunk_size = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'catalog:scanall'.
|
protected $signature = 'catalog:scanall'
|
||||||
' {type : Photo | Video }'.
|
.' {type : Photo | Video }'
|
||||||
' {--scanned : Rescan Scanned Photos}';
|
.' {--i|ignore : Ignore missing files}'
|
||||||
|
.' {--s|scan : Force Rescan of all files }';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -30,40 +37,128 @@ class CatalogScanAll extends Command
|
|||||||
protected $description = '(re)Scan Media';
|
protected $description = '(re)Scan Media';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function handle(): int
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$started = Carbon::now();
|
||||||
|
$class = $this->getModelType($this->argument('type'));
|
||||||
|
|
||||||
|
Log::info('Scanning disk: '.Storage::disk('nas')->path(''));
|
||||||
|
|
||||||
|
$c = 0;
|
||||||
|
// Scan files in dir, and make sure file lives in DB, (touch it if it does), otherwise create it
|
||||||
|
foreach (Storage::disk('nas')->directories($class::dir_prefix()) as $dir) {
|
||||||
|
Log::info(sprintf(' - DIR: %s',$dir));
|
||||||
|
|
||||||
|
// Take x files at a time and check the DB
|
||||||
|
foreach ($this->files($dir,$class::config,$class::dir_prefix())->chunk(self::chunk_size) as $chunk) {
|
||||||
|
$list = $class::whereIn('filename',$chunk)->get();
|
||||||
|
|
||||||
|
// If there is a new file found it wont be in the DB
|
||||||
|
if ($list->count() !== self::chunk_size)
|
||||||
|
foreach ($chunk->diff($list->pluck('filename')) as $file) {
|
||||||
|
Log::info(sprintf('Found new file [%s] - queueing scan',$file));
|
||||||
|
|
||||||
|
$o = new $class;
|
||||||
|
$o->filename = $file;
|
||||||
|
$o->file_signature = $o->getObjectOriginal('file_signature');
|
||||||
|
$o->save();
|
||||||
|
|
||||||
|
CatalogScan::dispatch($o)
|
||||||
|
->onQueue('scan');
|
||||||
|
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($list as $o) {
|
||||||
|
// Check the details are valid
|
||||||
|
if ($o->file_signature === $o->getObjectOriginal('file_signature')) {
|
||||||
|
// For sanity, we'll check a couple of other attrs
|
||||||
|
if (($o->width !== $o->getObjectOriginal('width')) || ($o->height !== $o->getObjectOriginal('height')))
|
||||||
|
Log::alert(sprintf('Dimensions [%s] (%s x %s) mismatch for [%s]',
|
||||||
|
$o->dimensions,
|
||||||
|
$o->getObjectOriginal('width'),
|
||||||
|
$o->getObjectOriginal('height'),
|
||||||
|
$o->file_name(FALSE)));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log::alert(sprintf('File Signature [%s] doesnt match [%s] for [%s]',
|
||||||
|
$o->getObjectOriginal('file_signature'),
|
||||||
|
$o->file_signature,
|
||||||
|
$o->file_name(FALSE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($o->signature !== $o->getObjectOriginal('signature')) {
|
||||||
|
Log::notice(sprintf('Updating image signature for [%s] to [%s] was [%s]',$o->filename,$o->signature,$o->getObjectOriginal('signature')));
|
||||||
|
|
||||||
|
$o->signature = $o->getObjectOriginal('signature');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($o->isDirty())
|
||||||
|
$o->save();
|
||||||
|
else
|
||||||
|
$o->touch();
|
||||||
|
|
||||||
|
if ($this->option('scan')) {
|
||||||
|
Log::info(sprintf('Forcing re-scan of [%s] - queued',$o->filename));
|
||||||
|
|
||||||
|
CatalogScan::dispatch($o)
|
||||||
|
->onQueue('scan');
|
||||||
|
}
|
||||||
|
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Checking for missing files');
|
||||||
|
|
||||||
|
// Find DB records before $started, check they exist (they shouldnt), and delete if not
|
||||||
|
if (! $this->option('ignore'))
|
||||||
|
foreach ($class::select(['id','filename'])->where('updated_at','<',$started)->cursor() as $o)
|
||||||
|
Log::error(sprintf('It appears that file [%s] is missing (%d)',$o->filename,$o->id));
|
||||||
|
|
||||||
|
Log::info(sprintf('Processed [%s]',$c));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Recursively find files that we should catalog
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @param string $dir Directory to get files from
|
||||||
|
* @param string $type Configuration key to refer to config())
|
||||||
|
* @param string $prefix Remove the prefix from the filename
|
||||||
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function files(string $dir,string $type,string $prefix): Collection
|
||||||
{
|
{
|
||||||
$class = $this->getModelType($this->argument('type'));
|
$files = collect(Storage::disk('nas')->files($dir))
|
||||||
|
->map(fn($item)=>preg_replace('#^'.$prefix.'#','',$item))
|
||||||
|
->filter(function($item) use ($type) {
|
||||||
|
return ((! ($x=strrpos($item,'.')))
|
||||||
|
|| (! in_array(strtolower(substr($item,$x+1)),config($type.'.import.accepted'))))
|
||||||
|
? NULL
|
||||||
|
: $item;
|
||||||
|
});
|
||||||
|
|
||||||
if ($this->option('scanned')) {
|
if (! $this->depth)
|
||||||
$class::whereNotNull('scanned')
|
return $files;
|
||||||
->update(['scanned'=>NULL]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$c = 0;
|
if (is_numeric($this->depth))
|
||||||
$class::NotScanned()->each(function ($item) use ($c) {
|
$this->depth--;
|
||||||
if ($item->remove) {
|
|
||||||
Log::warning(sprintf('Not scanning [%s], marked for removal',$item->id));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->dispatch((new CatalogScan($item))->onQueue('scan'));
|
foreach (Storage::disk('nas')->directories($dir) as $dir)
|
||||||
$c++;
|
$files = $files->merge($this->files($dir,$type,$prefix));
|
||||||
});
|
|
||||||
|
|
||||||
Log::info(sprintf('Processed [%s]',$c));
|
if (is_numeric($this->depth))
|
||||||
|
$this->depth++;
|
||||||
|
|
||||||
|
return $files;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
||||||
|
|
||||||
use App\Jobs\CatalogVerify as Job;
|
|
||||||
|
|
||||||
class CatalogVerify extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'catalog:verify'.
|
|
||||||
' {type : Photo | Video }';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Verify media on disk and in the DB';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
if ($this->argument('type')) {
|
|
||||||
Job::dispatch($this->argument('type'))->onQueue('scan');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Log;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use App\Model\Photo;
|
|
||||||
|
|
||||||
class PhotoUpdate extends Command
|
|
||||||
{
|
|
||||||
use \App\Traits\Files;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'photo:update
|
|
||||||
{--dir= : Directory to Parse}
|
|
||||||
{--file= : File to import}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Update Signatures';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$files = $this->getFiles(['dir'=>$this->option('dir'),'file'=>$this->option('file')]);
|
|
||||||
if (! count($files))
|
|
||||||
exit;
|
|
||||||
|
|
||||||
// Show a progress bar
|
|
||||||
$bar = $this->output->createProgressBar(count($files));
|
|
||||||
$bar->setFormat("%current%/%max% [%bar%] %percent:3s%% (%memory%) (%remaining%) ");
|
|
||||||
|
|
||||||
$c = 0;
|
|
||||||
foreach ($files as $file)
|
|
||||||
{
|
|
||||||
$bar->advance();
|
|
||||||
|
|
||||||
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file))
|
|
||||||
{
|
|
||||||
$this->warn(sprintf('Ignoring file [%s]',$file));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),config('photo.import.accepted')))
|
|
||||||
{
|
|
||||||
$this->warn(sprintf('Ignoring [%s]',$file));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->option('verbose'))
|
|
||||||
$this->info(sprintf('Processing file [%s]',$file));
|
|
||||||
|
|
||||||
$c++;
|
|
||||||
|
|
||||||
$po = Photo::where('filename',$file)->first();
|
|
||||||
|
|
||||||
if (is_null($po))
|
|
||||||
{
|
|
||||||
$this->error(sprintf('File is not in the database [%s]?',$file));
|
|
||||||
Log::error(sprintf('%s: File is not in the database [%s]?',__METHOD__,$file));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$po->signature = $po->property('signature');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$po->thumbnail = exif_thumbnail($po->file_path());
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// @todo Couldnt get the thumbnail, so we should create one.
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($po->isDirty())
|
|
||||||
{
|
|
||||||
if (count($po->getDirty()) > 1 OR ! array_key_exists('signature',$po->getDirty()))
|
|
||||||
$this->error(sprintf('More than the signature changed for [%s] (%s)?',$po->id,join('|',array_keys($po->getDirty()))));
|
|
||||||
|
|
||||||
$this->info(sprintf('Signature update for [%s]',$po->id));
|
|
||||||
$po->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$bar->finish();
|
|
||||||
|
|
||||||
return $this->info(sprintf('Images processed: %s',$c));
|
|
||||||
}
|
|
||||||
}
|
|
@ -38,14 +38,9 @@ class PhotoController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function info(Photo $o)
|
|
||||||
{
|
|
||||||
return view('photo.view',['o'=>$o]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function thumbnail(Photo $o)
|
public function thumbnail(Photo $o)
|
||||||
{
|
{
|
||||||
return response($o->thumbnail(TRUE))
|
return response($o->thumbnail())
|
||||||
->header('Content-Type','image/jpeg');
|
->header('Content-Type','image/jpeg');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,9 +49,16 @@ class PhotoController extends Controller
|
|||||||
$o->remove = NULL;
|
$o->remove = NULL;
|
||||||
$o->save();
|
$o->save();
|
||||||
|
|
||||||
return redirect()->action('PhotoController@info',[$o->id]);
|
return redirect()
|
||||||
|
->action('PhotoController@info',[$o->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the photo to the browser
|
||||||
|
*
|
||||||
|
* @param Photo $o
|
||||||
|
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Foundation\Application|\Illuminate\Http\Response
|
||||||
|
*/
|
||||||
public function view(Photo $o)
|
public function view(Photo $o)
|
||||||
{
|
{
|
||||||
return response($o->image())
|
return response($o->image())
|
||||||
|
@ -2,39 +2,92 @@
|
|||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
|
|
||||||
use App\Models\Abstracted\Catalog;
|
use App\Models\Abstracted\Catalog;
|
||||||
|
|
||||||
class CatalogScan extends Job implements ShouldQueue
|
class CatalogScan implements ShouldQueue, ShouldBeUnique
|
||||||
{
|
{
|
||||||
use InteractsWithQueue, SerializesModels;
|
use InteractsWithQueue,Queueable,SerializesModels;
|
||||||
|
|
||||||
// Our object
|
// Our object
|
||||||
private $o = NULL;
|
private Catalog $o;
|
||||||
|
private bool $show_dirty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Catalog $o) {
|
public function __construct(Catalog $o,bool $show_dirty=FALSE) {
|
||||||
$this->o = $o;
|
$this->o = $o->withoutRelations();
|
||||||
|
$this->show_dirty = $show_dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xmiddleware(): array
|
||||||
|
{
|
||||||
|
return [new WithoutOverlapping($this->o->id)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
Log::info(sprintf('%s: Scanning [%s|%s]',__METHOD__,$this->o->objecttype(),$this->o->id));
|
Log::info(sprintf('%s: Scanning [%s|%s]',__METHOD__,$this->o->objecttype(),$this->o->id));
|
||||||
|
|
||||||
Artisan::call('catalog:scan',['type'=>$this->o->objecttype(),'id'=>$this->o->id]);
|
if (! $this->o->isReadable()) {
|
||||||
|
Log::alert(sprintf('Ignoring [%s], it is not readable',$this->o->file_name(FALSE)));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->o->init();
|
||||||
|
|
||||||
|
// If this is a duplicate
|
||||||
|
$x = $this->o->myduplicates()->get();
|
||||||
|
if (count($x)) {
|
||||||
|
foreach ($x as $this->oo) {
|
||||||
|
// And that photo is not marked as a duplicate
|
||||||
|
if (! $this->oo->duplicate) {
|
||||||
|
$this->o->duplicate = TRUE;
|
||||||
|
Log::alert(sprintf('Image [%s] marked as a duplicate',$this->o->filename));
|
||||||
|
|
||||||
|
// If the file signature also matches, we'll mark it for deletion
|
||||||
|
if ($this->oo->file_signature && ($this->o->file_signature == $this->oo->file_signature)) {
|
||||||
|
Log::alert(sprintf('Image [%s] marked for deletion',$this->o->filename));
|
||||||
|
$this->o->remove = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->o->scanned = TRUE;
|
||||||
|
|
||||||
|
if ($this->o->getDirty()) {
|
||||||
|
Log::alert(sprintf('Image [%s] metadata changed',$this->o->filename));
|
||||||
|
|
||||||
|
if ($this->show_dirty)
|
||||||
|
dump(['id'=>$this->o->id,'data'=>$this->o->getDirty()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the file signature changed, abort the update.
|
||||||
|
if ($this->o->getOriginal('file_signature') && $this->o->wasChanged('file_signature')) {
|
||||||
|
dump(['old'=>$this->o->getOriginal('file_signature'),'new'=>$this->o->file_signature]);
|
||||||
|
abort(500,'File Signature Changed?');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->o->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
use App\Traits\Files;
|
|
||||||
use App\Traits\Type;
|
|
||||||
|
|
||||||
class CatalogVerify extends Job implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, Queueable, InteractsWithQueue, SerializesModels, Type, Files;
|
|
||||||
|
|
||||||
// What we should verify
|
|
||||||
private $type = NULL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(string $type) {
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(sprintf('%s: Scanning [%s]',__METHOD__,$this->type));
|
|
||||||
|
|
||||||
// Go through DB and verify files exist
|
|
||||||
$class = $this->getModelType($this->type);
|
|
||||||
|
|
||||||
$good = $bad = $ugly = 0;
|
|
||||||
|
|
||||||
$class::select('*')->each(function($o) use ($good,$bad,$ugly) {
|
|
||||||
if (! file_exists($o->file_name_current(FALSE))) {
|
|
||||||
Log::error(sprintf('Media doesnt exist: [%s] (%d:%s)',$this->type,$o->id,$o->file_name_current(FALSE)));
|
|
||||||
$bad++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($x=md5_file($o->file_name_current(FALSE))) !== $o->file_signature) {
|
|
||||||
Log::error(sprintf('Media MD5 doesnt match DB: [%s] (%d:%s) [%s:%s]',$this->type,$o->id,$o->file_name_current(FALSE),$x,$o->file_signature));
|
|
||||||
$ugly++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$good++;
|
|
||||||
});
|
|
||||||
|
|
||||||
Log::info(sprintf('DB Media Verify Complete: [%s] Good: [%d], Missing: [%d], Changed: [%d]',$this->type,$good,$bad,$ugly));
|
|
||||||
|
|
||||||
// Go through filesystem and see that a record exists in the DB, if not add it.
|
|
||||||
$parentdir = config($this->type.'.dir');
|
|
||||||
|
|
||||||
$good = $bad = 0;
|
|
||||||
|
|
||||||
foreach ($this->dirlist($parentdir) as $dir) {
|
|
||||||
foreach ($this->getFiles(['dir'=>$dir,'file'=>NULL],$this->type) as $file) {
|
|
||||||
if (! $class::where('filename',$file)->count()) {
|
|
||||||
$bad++;
|
|
||||||
Log::error(sprintf('File not in DB: [%s] (%s)',$this->type,$file));
|
|
||||||
} else {
|
|
||||||
$good++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info(sprintf('File Media Verify Complete: [%s] Good: [%d], Not In DB: [%d]',$this->type,$good,$bad));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively get a list of dirs
|
|
||||||
* @param $path
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
|
||||||
private function dirlist($path)
|
|
||||||
{
|
|
||||||
$list = collect();
|
|
||||||
|
|
||||||
$list->push($path);
|
|
||||||
|
|
||||||
foreach (glob($path.'/*',GLOB_ONLYDIR) as $dir) {
|
|
||||||
foreach ($this->dirlist($dir) as $subdir)
|
|
||||||
$list->push($subdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,20 +5,56 @@ namespace App\Models\Abstracted;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
use App\Models\{Person,Software,Tag};
|
use App\Casts\PostgresBytea;
|
||||||
|
use App\Models\{Make,Person,Software,Tag};
|
||||||
|
|
||||||
abstract class Catalog extends Model
|
abstract class Catalog extends Model
|
||||||
{
|
{
|
||||||
protected static $includeSubSecTime = FALSE;
|
protected static $includeSubSecTime = FALSE;
|
||||||
protected $dates = ['created','created_manual'];
|
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
'created_manual' => 'datetime',
|
||||||
'subsectime' => 'int',
|
'subsectime' => 'int',
|
||||||
|
'thumbnail' => PostgresBytea::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected const fs = 'nas';
|
||||||
|
|
||||||
|
private ?string $move_reason;
|
||||||
|
|
||||||
|
protected array $init = [];
|
||||||
|
|
||||||
|
/* STATIC */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the prefix for the file path - dependant on the object
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function dir_prefix(): string
|
||||||
|
{
|
||||||
|
return config(static::config.'.dir').'/';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trim a string
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param int $chrs
|
||||||
|
* @return string
|
||||||
|
* @todo This should go in as a helper
|
||||||
|
*/
|
||||||
|
public static function stringtrim(string $string,int $chrs=6)
|
||||||
|
{
|
||||||
|
return sprintf('%s...%s',substr($string,0,$chrs),substr($string,-1*$chrs));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RELATIONS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* People in Multimedia Object
|
* People in Multimedia Object
|
||||||
*
|
*
|
||||||
@ -49,19 +85,19 @@ abstract class Catalog extends Model
|
|||||||
return $this->belongsToMany(Tag::class);
|
return $this->belongsToMany(Tag::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SCOPES */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find records marked as duplicate
|
* Find records marked as duplicate
|
||||||
*
|
*
|
||||||
* @param $query
|
* @param $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function scopeDuplicates($query) {
|
public function scopeDuplicates($query)
|
||||||
$query->notRemove()
|
{
|
||||||
|
return $query->notRemove()
|
||||||
->where('duplicate',TRUE)
|
->where('duplicate',TRUE)
|
||||||
->where(function($q) {
|
->where(fn($q)=>$q->where('ignore_duplicate','<>',TRUE)->orWhereNull('ignore_duplicate'));
|
||||||
$q->Where('ignore_duplicate','<>',TRUE)
|
|
||||||
->orWhereNull('ignore_duplicate');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,29 +114,20 @@ abstract class Catalog extends Model
|
|||||||
$query->where('id','<>',$this->attributes['id']);
|
$query->where('id','<>',$this->attributes['id']);
|
||||||
|
|
||||||
// Skip ignore dups
|
// Skip ignore dups
|
||||||
$query->where(function($q) {
|
$query->where(fn($q)=>$q->whereNull('ignore_duplicate')->orWhere('ignore_duplicate',FALSE));
|
||||||
$q->whereNull('ignore_duplicate')
|
|
||||||
->orWhere('ignore_duplicate','=',0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Exclude those marked as remove
|
// Exclude those marked as remove
|
||||||
$query->where(function ($q) {
|
$query->where(fn($q)=>$q->where('remove','<>',TRUE));
|
||||||
$q->where('remove','<>',TRUE)
|
|
||||||
->orWhere('remove','=',NULL);
|
|
||||||
});
|
|
||||||
|
|
||||||
$query->where(function ($q) {
|
$query->where(function($q) {
|
||||||
$q->where('signature','=',$this->attributes['signature'])
|
$q->when($this->attributes['signature'],fn($q)=>$q->where('signature','=',$this->attributes['signature']))
|
||||||
->orWhere('file_signature','=',$this->attributes['file_signature'])
|
->orWhere('file_signature','=',$this->attributes['file_signature'])
|
||||||
|
|
||||||
// Where the signature is the same
|
// Where the signature is the same
|
||||||
->orWhere(function($q) {
|
->orWhere(function($q) {
|
||||||
// Or they have the same time taken with the same camera
|
// Or they have the same time taken with the same camera
|
||||||
if ($this->attributes['created'] AND $this->software_id) {
|
if ($this->attributes['created'] AND $this->software_id) {
|
||||||
$q->where(function ($q) {
|
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created'])->orWhere('created_manual','=',$this->attributes['created']));
|
||||||
$q->where('created','=',$this->attributes['created'])
|
|
||||||
->orWhere('created_manual','=',$this->attributes['created']);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (static::$includeSubSecTime)
|
if (static::$includeSubSecTime)
|
||||||
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
||||||
@ -108,10 +135,7 @@ abstract class Catalog extends Model
|
|||||||
$q->where('software_id','=',$this->attributes['software_id']);
|
$q->where('software_id','=',$this->attributes['software_id']);
|
||||||
|
|
||||||
} elseif ($this->attributes['created_manual'] AND $this->software_id) {
|
} elseif ($this->attributes['created_manual'] AND $this->software_id) {
|
||||||
$q->where(function ($q) {
|
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created_manual'])->orWhere('created_manual','=',$this->attributes['created_manual']));
|
||||||
$q->where('created','=',$this->attributes['created_manual'])
|
|
||||||
->orWhere('created_manual','=',$this->attributes['created_manual']);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (static::$includeSubSecTime)
|
if (static::$includeSubSecTime)
|
||||||
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
||||||
@ -120,6 +144,8 @@ abstract class Catalog extends Model
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,15 +155,11 @@ abstract class Catalog extends Model
|
|||||||
*/
|
*/
|
||||||
public function scopeNotDuplicate($query)
|
public function scopeNotDuplicate($query)
|
||||||
{
|
{
|
||||||
return $query->where(function($query)
|
return $query->where(
|
||||||
{
|
fn($q)=>$q->where('duplicate','<>',TRUE)
|
||||||
$query->where('duplicate','<>',TRUE)
|
|
||||||
->orWhere('duplicate','=',NULL)
|
->orWhere('duplicate','=',NULL)
|
||||||
->orWhere(function($q) {
|
->orWhere(fn($q)=>$q->where('duplicate','=',TRUE)->where('ignore_duplicate','=',TRUE))
|
||||||
$q->where('duplicate','=',TRUE)
|
);
|
||||||
->where('ignore_duplicate','=',TRUE);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,11 +169,7 @@ abstract class Catalog extends Model
|
|||||||
*/
|
*/
|
||||||
public function scopeNotRemove($query)
|
public function scopeNotRemove($query)
|
||||||
{
|
{
|
||||||
return $query->where(function($query)
|
return $query->where(fn($q)=>$q->where('remove','<>',TRUE)->orWhere('remove','=',NULL));
|
||||||
{
|
|
||||||
$query->where('remove','<>',TRUE)
|
|
||||||
->orWhere('remove','=',NULL);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,27 +179,33 @@ abstract class Catalog extends Model
|
|||||||
*/
|
*/
|
||||||
public function scopeNotScanned($query)
|
public function scopeNotScanned($query)
|
||||||
{
|
{
|
||||||
return $query->where(function($query)
|
return $query->where(fn($q)=>$q->where('scanned','<>',TRUE)->orWhere('scanned','=',NULL));
|
||||||
{
|
|
||||||
$query->where('scanned','<>',TRUE)
|
|
||||||
->orWhere('scanned','=',NULL);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Children objects must inherit this methods
|
/* ABSTRACTS */
|
||||||
abstract public function setLocation();
|
|
||||||
abstract public function setSubSecTime();
|
abstract public function getObjectOriginal(string $property): mixed;
|
||||||
abstract public function setThumbnail();
|
|
||||||
abstract public function getHtmlImageURL();
|
/* ATTRIBUTES */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date the multimedia was created
|
* Return the time the media was created on the device
|
||||||
|
*
|
||||||
|
* This will be (in priority order)
|
||||||
|
* + the value of created_manual (Carbon)
|
||||||
|
* + the value of created
|
||||||
|
*
|
||||||
|
* @param string|null $date
|
||||||
|
* @return Carbon|null
|
||||||
*/
|
*/
|
||||||
public function date_taken(): string
|
public function getCreatedAttribute(string $date=NULL): ?Carbon
|
||||||
{
|
{
|
||||||
return $this->created
|
$result = $this->created_manual ?: ($date ? Carbon::create($date) : NULL);
|
||||||
? $this->created->format('Y-m-d H:i:s').(static::$includeSubSecTime ? sprintf('.%03d',$this->subsectime) : '')
|
|
||||||
: 'UNKNOWN';
|
if ($result && static::$includeSubSecTime)
|
||||||
|
$result->microseconds($this->subsectime*1000);
|
||||||
|
|
||||||
|
return $result ?: $this->getObjectOriginal('creation_date');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,7 +213,7 @@ abstract class Catalog extends Model
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function device(): string
|
public function getDeviceAttribute(): string
|
||||||
{
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
|
|
||||||
@ -209,61 +233,105 @@ abstract class Catalog extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the date of the file
|
* Return item dimensions
|
||||||
* @todo return Carbon date or NULL
|
|
||||||
*/
|
*/
|
||||||
public function file_date($type,$format=FALSE)
|
public function getDimensionsAttribute(): string
|
||||||
{
|
{
|
||||||
if (! is_readable($this->file_path()))
|
return $this->width.'x'.$this->height;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
switch ($type)
|
|
||||||
{
|
|
||||||
case 'a': $t = fileatime($this->file_path());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c': $t = filectime($this->file_path());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'm': $t = filemtime($this->file_path());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $format ? date('d-m-Y H:i:s',$t) : $t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return what the filename should be.
|
* Return the file size
|
||||||
*
|
*
|
||||||
|
* @return int|null
|
||||||
|
*/
|
||||||
|
public function getFileSizeAttribute(): ?int
|
||||||
|
{
|
||||||
|
return (! $this->isReadable()) ? NULL : filesize($this->file_name(FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGPSAttribute(): ?string
|
||||||
|
{
|
||||||
|
return ($this->gps_lat && $this->gps_lon)
|
||||||
|
? sprintf('%s/%s',$this->gps_lat,$this->gps_lon)
|
||||||
|
: NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* METHODS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date the multimedia was created
|
||||||
|
*
|
||||||
|
* @deprecated use $this->created
|
||||||
|
*/
|
||||||
|
public function date_taken(): string
|
||||||
|
{
|
||||||
|
Log::alert(__METHOD__.' deprecated');
|
||||||
|
return $this->created;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated use $this->device */
|
||||||
|
public function device(): string
|
||||||
|
{
|
||||||
|
Log::alert(__METHOD__.' deprecated');
|
||||||
|
return $this->device;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the date of the file
|
||||||
|
*/
|
||||||
|
public function file_date(string $type): ?Carbon
|
||||||
|
{
|
||||||
|
if (! $this->isReadable())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
$t = NULL;
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'a': $t = fileatime($this->file_name(FALSE));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'c': $t = filectime($this->file_name(FALSE));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'm': $t = filemtime($this->file_name(FALSE));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $t ? Carbon::createfromTimestamp($t) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the filename.
|
||||||
|
* If short is TRUE, it is the filename that it should be called (and can be compared to $this->filename)
|
||||||
|
* If short is FALSE, it is the true path of the actual file
|
||||||
|
*
|
||||||
|
* @param bool $short
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function file_name(bool $short=TRUE): string
|
public function file_name(bool $short=TRUE): string
|
||||||
{
|
{
|
||||||
// If the date created is not set, the file name will be based on the ID of the file.
|
if ($short || preg_match('#^/#',$this->filename)) {
|
||||||
$file = sprintf('%s.%s',(is_null($this->created)
|
// If the date created is not set, the file name will be based on the ID of the file.
|
||||||
? sprintf('UNKNOWN/%07s',$this->file_path_id())
|
$file = sprintf('%s.%s',
|
||||||
: $this->created->format('Y/m/d-His').
|
(is_null($this->created)
|
||||||
((! is_null($this->subsectime)) ? sprintf('_%03d',$this->subsectime) : '' ).
|
? sprintf('UNKNOWN/%07s',$this->file_path_id())
|
||||||
sprintf('-%05s',$this->id))
|
: $this->created->format('Y/m/d-His').
|
||||||
,$this->type()
|
($this->subsectime ? sprintf('_%03d',$this->subsectime) : '' ).
|
||||||
);
|
sprintf('-%05s',$this->id)),
|
||||||
|
$this->type()
|
||||||
|
);
|
||||||
|
|
||||||
return (($short OR preg_match('/^\//',$file)) ? '' : config($this->type.'.dir').DIRECTORY_SEPARATOR).$file;
|
return $file;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
} else
|
||||||
* Return the current filename
|
return Storage::disk(self::fs)
|
||||||
*
|
->path(config(static::config.'.dir').DIRECTORY_SEPARATOR.$this->filename);
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function file_name_current(bool $short=TRUE): string
|
|
||||||
{
|
|
||||||
return (($short OR preg_match('/^\//',$this->filename)) ? '' : config($this->type.'.dir').DIRECTORY_SEPARATOR).$this->filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the new name for the image
|
* Determine the new name for the image
|
||||||
* @deprecated use $this->file_name()
|
* @deprecated use $this->file_name(FALSE) to determine the name, and file_name(TRUE) to determine the new name
|
||||||
*/
|
*/
|
||||||
public function file_path($short=FALSE,$new=FALSE)
|
public function file_path($short=FALSE,$new=FALSE)
|
||||||
{
|
{
|
||||||
@ -277,62 +345,37 @@ abstract class Catalog extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate a file path ID based on the id of the file
|
* Calculate a file path ID based on the id of the file
|
||||||
|
*
|
||||||
|
* We use this when we cannot determine the create time of the image
|
||||||
*/
|
*/
|
||||||
public function file_path_id($sep=3,$depth=9): string
|
public function file_path_id($sep=3,$depth=9): string
|
||||||
{
|
{
|
||||||
return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/');
|
return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the file signature
|
|
||||||
*/
|
|
||||||
public function file_signature($short=FALSE): string
|
|
||||||
{
|
|
||||||
return $short ? static::stringtrim($this->file_signature) : $this->file_signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the file size
|
* Return the file size
|
||||||
* @deprecated
|
* @deprecated use $this->getFileSizeAttribute())
|
||||||
*/
|
*/
|
||||||
public function file_size()
|
public function file_size()
|
||||||
{
|
{
|
||||||
return (! is_readable($this->file_path())) ? NULL : filesize($this->file_path());
|
Log::alert(__METHOD__.' deprecated');
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedAttribute()
|
return (! is_readable($this->file_name(FALSE))) ? NULL : filesize($this->file_name(FALSE));
|
||||||
{
|
|
||||||
return $this->created_manual ?: ($this->attributes['created'] ? $this->asDateTime($this->attributes['created']) : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return item dimensions
|
|
||||||
*/
|
|
||||||
public function getDimensionsAttribute(): string
|
|
||||||
{
|
|
||||||
return $this->width.'x'.$this->height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML Checkbox for duplicate
|
* Return HTML Checkbox for duplicate
|
||||||
|
* @deprecated use a component
|
||||||
*/
|
*/
|
||||||
public function getDuplicateCheckboxAttribute()
|
public function getDuplicateCheckboxAttribute()
|
||||||
{
|
{
|
||||||
return $this->HTMLCheckbox('duplicate',$this->id,$this->duplicate);
|
return $this->HTMLCheckbox('duplicate',$this->id,$this->duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the file size
|
|
||||||
*
|
|
||||||
* @return false|int|null
|
|
||||||
*/
|
|
||||||
public function getFileSizeAttribute()
|
|
||||||
{
|
|
||||||
return (! is_readable($this->file_path())) ? NULL : filesize($this->file_path());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML Checkbox for flagged
|
* Return HTML Checkbox for flagged
|
||||||
|
* @deprecated use a component
|
||||||
*/
|
*/
|
||||||
public function getFlagCheckboxAttribute()
|
public function getFlagCheckboxAttribute()
|
||||||
{
|
{
|
||||||
@ -341,6 +384,7 @@ abstract class Catalog extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML Checkbox for ignore
|
* Return HTML Checkbox for ignore
|
||||||
|
* @deprecated use a component
|
||||||
*/
|
*/
|
||||||
public function getIgnoreCheckboxAttribute()
|
public function getIgnoreCheckboxAttribute()
|
||||||
{
|
{
|
||||||
@ -348,7 +392,7 @@ abstract class Catalog extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated use a component
|
||||||
*/
|
*/
|
||||||
public function getDuplicateTextAttribute()
|
public function getDuplicateTextAttribute()
|
||||||
{
|
{
|
||||||
@ -356,7 +400,7 @@ abstract class Catalog extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated use a component
|
||||||
*/
|
*/
|
||||||
public function getFlagTextAttribute()
|
public function getFlagTextAttribute()
|
||||||
{
|
{
|
||||||
@ -365,32 +409,167 @@ abstract class Catalog extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML Checkbox for remove
|
* Return HTML Checkbox for remove
|
||||||
|
* @deprecated use a component
|
||||||
*/
|
*/
|
||||||
public function getRemoveCheckboxAttribute()
|
public function getRemoveCheckboxAttribute()
|
||||||
{
|
{
|
||||||
return $this->HTMLCheckbox('remove',$this->id,$this->remove);
|
return $this->HTMLCheckbox('remove',$this->id,$this->remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the object type
|
|
||||||
* @return string
|
|
||||||
* @deprecated Use objecttype()
|
|
||||||
*/
|
|
||||||
public function getTypeAttribute(): string
|
|
||||||
{
|
|
||||||
switch(get_class($this)) {
|
|
||||||
case 'App\Models\Photo': return 'photo';
|
|
||||||
case 'App\Models\Video': return 'video';
|
|
||||||
default: return 'unknown';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the GPS coordinates
|
* Display the GPS coordinates
|
||||||
|
* @deprecated use getGPSAttribute()
|
||||||
*/
|
*/
|
||||||
public function gps(): string
|
public function gps(): string
|
||||||
{
|
{
|
||||||
return ($this->gps_lat AND $this->gps_lon) ? sprintf('%s/%s',$this->gps_lat,$this->gps_lon) : 'UNKNOWN';
|
return $this->getGPSAttribute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an HTML checkbox
|
||||||
|
* @deprecated use a component
|
||||||
|
*/
|
||||||
|
protected function HTMLCheckbox($name,$id,$value)
|
||||||
|
{
|
||||||
|
return sprintf('<input type="checkbox" name="%s[%s]" value="1"%s>',$name,$id,$value ? ' checked="checked"' : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ID Info link
|
||||||
|
* @deprecated use a component
|
||||||
|
*/
|
||||||
|
protected function HTMLLinkAttribute($id,$url)
|
||||||
|
{
|
||||||
|
return sprintf('<a href="%s" target="%s">%s</a>',url($url,$id),$id,$id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set values from the media object
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function init(): void
|
||||||
|
{
|
||||||
|
foreach ($this->init as $item) {
|
||||||
|
Log::debug(sprintf('Init item [%s]',$item));
|
||||||
|
|
||||||
|
switch ($item) {
|
||||||
|
case 'creation_date':
|
||||||
|
$this->created = $this->getObjectOriginal('creation_date');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'gps':
|
||||||
|
$this->gps_lat = $this->getObjectOriginal('gps_lat');
|
||||||
|
$this->gps_lon = $this->getObjectOriginal('gps_lon');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'heightwidth':
|
||||||
|
$this->height = $this->getObjectOriginal('height');
|
||||||
|
$this->width = $this->getObjectOriginal('width');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'signature':
|
||||||
|
$this->signature = $this->getObjectOriginal('signature');
|
||||||
|
$this->file_signature = $this->getObjectOriginal('file_signature');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'software':
|
||||||
|
$ma = NULL;
|
||||||
|
|
||||||
|
if ($x=$this->getObjectOriginal('make'))
|
||||||
|
$ma = Make::firstOrCreate([
|
||||||
|
'name'=>$x,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$mo = \App\Models\Model::firstOrCreate([
|
||||||
|
'name'=>$this->getObjectOriginal('model') ?: NULL,
|
||||||
|
'make_id'=>$ma?->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$so = Software::firstOrCreate([
|
||||||
|
'name'=>$this->getObjectOriginal('software') ?: NULL,
|
||||||
|
'model_id'=>$mo->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->software_id = $so->id;
|
||||||
|
|
||||||
|
case 'subsectime':
|
||||||
|
$this->subsectime = $this->getObjectOriginal($item);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \Exception('Unknown init item: '.$item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->custom_init();
|
||||||
|
|
||||||
|
Log::debug('Init result',['dirty'=>$this->getDirty()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the file require moving
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isMoveable(): bool
|
||||||
|
{
|
||||||
|
// No change to the name
|
||||||
|
$this->move_reason = 'Filenames match already';
|
||||||
|
if ($this->filename === $this->file_name())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// If there is already a file in the target.
|
||||||
|
// @todo If the target file is to be deleted, we could move this file
|
||||||
|
$this->move_reason = 'Target file exists';
|
||||||
|
if (Storage::disk(self::fs)->exists($this->file_name()))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// Test if the source is readable
|
||||||
|
$this->move_reason = 'Source is not readable';
|
||||||
|
if (! $this->isReadable())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// Test if the dir is writable (so we can remove the file)
|
||||||
|
$this->move_reason = 'Source parent dir not writable';
|
||||||
|
if (! $this->isParentWritable(dirname($this->file_name(FALSE))))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// Test if the target dir is writable
|
||||||
|
// @todo The target dir may not exist yet, so we should check that a parent exists and is writable.
|
||||||
|
$this->move_reason = 'Target parent dir doesnt is not writable';
|
||||||
|
if (! $this->isParentWritable(dirname($this->file_name(FALSE))))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// Otherwise we can move it
|
||||||
|
$this->move_reason = NULL;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isMoveableReason(): ?string
|
||||||
|
{
|
||||||
|
return isset($this->move_reason) ? $this->move_reason : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the parent dir is writable
|
||||||
|
*
|
||||||
|
* @param string $dir
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isParentWritable(string $dir): bool
|
||||||
|
{
|
||||||
|
$path = Storage::disk(self::fs)->path($dir);
|
||||||
|
|
||||||
|
if (Storage::disk(self::fs)->exists($dir) && is_dir($path) && is_writable($path))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
elseif ($path === dirname($path))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
else
|
||||||
|
return ($this->isParentWritable(dirname($dir)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -400,41 +579,7 @@ abstract class Catalog extends Model
|
|||||||
*/
|
*/
|
||||||
public function isReadable(): bool
|
public function isReadable(): bool
|
||||||
{
|
{
|
||||||
return is_readable($this->file_path());
|
return is_readable($this->file_name(FALSE));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an HTML checkbox
|
|
||||||
*/
|
|
||||||
protected function HTMLCheckbox($name,$id,$value)
|
|
||||||
{
|
|
||||||
return sprintf('<input type="checkbox" name="%s[%s]" value="1"%s>',$name,$id,$value ? ' checked="checked"' : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get ID Info link
|
|
||||||
*/
|
|
||||||
protected function HTMLLinkAttribute($id,$url)
|
|
||||||
{
|
|
||||||
return sprintf('<a href="%s" target="%s">%s</a>',url($url,$id),$id,$id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the parent dir is writable
|
|
||||||
*
|
|
||||||
* @param $dir
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isParentWritable($dir): bool
|
|
||||||
{
|
|
||||||
if (file_exists($dir) AND is_writable($dir) AND is_dir($dir))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
elseif ($dir == dirname($dir) OR file_exists($dir))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
else
|
|
||||||
return ($this->isParentWritable(dirname($dir)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -445,44 +590,20 @@ abstract class Catalog extends Model
|
|||||||
*/
|
*/
|
||||||
public function moveable()
|
public function moveable()
|
||||||
{
|
{
|
||||||
// If the source and target are the same, we dont need to move it
|
Log::alert(__METHOD__.' deprecated');
|
||||||
if ($this->file_path() == $this->file_path(FALSE,TRUE))
|
return $this->isMoveable();
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// If there is already a file in the target.
|
|
||||||
// @todo If the target file is to be deleted, we could move this file
|
|
||||||
if (file_exists($this->file_path(FALSE,TRUE)))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Test if the source is readable
|
|
||||||
if (! is_readable($this->file_path()))
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
// Test if the dir is writable (so we can remove the file)
|
|
||||||
if (! $this->isParentWritable(dirname($this->file_path())))
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
// Test if the target dir is writable
|
|
||||||
// @todo The target dir may not exist yet, so we should check that a parent exists and is writable.
|
|
||||||
if (! $this->isParentWritable($this->file_path(FALSE,TRUE)))
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the id of the previous record
|
* Get the id of the next record
|
||||||
*/
|
*/
|
||||||
public function next()
|
public function next(): ?self
|
||||||
{
|
{
|
||||||
return DB::table($this->getTable())
|
return static::where('id','>',$this->id)
|
||||||
->where('id','>',$this->id)
|
|
||||||
->orderby('id','ASC')
|
->orderby('id','ASC')
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function property(string $property);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return my class shortname
|
* Return my class shortname
|
||||||
*/
|
*/
|
||||||
@ -494,62 +615,21 @@ abstract class Catalog extends Model
|
|||||||
/**
|
/**
|
||||||
* Get the id of the previous record
|
* Get the id of the previous record
|
||||||
*/
|
*/
|
||||||
public function previous()
|
public function previous(): ?self
|
||||||
{
|
{
|
||||||
return DB::table($this->getTable())
|
return static::where('id','<',$this->id)
|
||||||
->where('id','<',$this->id)
|
|
||||||
->orderby('id','DESC')
|
->orderby('id','DESC')
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDateCreated()
|
|
||||||
{
|
|
||||||
$this->created = $this->property('creationdate') ?: NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setHeightWidth()
|
|
||||||
{
|
|
||||||
$this->height = $this->property('height');
|
|
||||||
$this->width = $this->property('width');
|
|
||||||
$this->orientation = $this->property('orientation');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSignature()
|
|
||||||
{
|
|
||||||
$this->signature = $this->property('signature');
|
|
||||||
|
|
||||||
$this->file_signature = md5_file($this->file_path());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the media signature
|
* Display the media signature
|
||||||
*/
|
*/
|
||||||
public function signature($short=FALSE)
|
public function signature($short=FALSE)
|
||||||
{
|
{
|
||||||
return ($short AND $this->signature) ? static::stringtrim($this->signature) : $this->signature;
|
return ($short && $this->signature)
|
||||||
}
|
? static::stringtrim($this->signature)
|
||||||
|
: $this->signature;
|
||||||
/**
|
|
||||||
* Trim a string
|
|
||||||
*
|
|
||||||
* @param string $string
|
|
||||||
* @param int $chrs
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function stringtrim(string $string,int $chrs=6)
|
|
||||||
{
|
|
||||||
return sprintf('%s...%s',substr($string,0,$chrs),substr($string,-1*$chrs));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @param string $string
|
|
||||||
* @param int $chrs
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function signaturetrim(string $string,int $chrs=6)
|
|
||||||
{
|
|
||||||
return static::stringtrim($string,$chrs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -560,7 +640,8 @@ abstract class Catalog extends Model
|
|||||||
return $this->filename !== $this->file_name();
|
return $this->filename !== $this->file_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function TextTrueFalse($value): string
|
/** @deprecated is this really needed? */
|
||||||
|
private function TextTrueFalse($value): string
|
||||||
{
|
{
|
||||||
return $value ? 'TRUE' : 'FALSE';
|
return $value ? 'TRUE' : 'FALSE';
|
||||||
}
|
}
|
||||||
@ -595,7 +676,7 @@ abstract class Catalog extends Model
|
|||||||
->orWhere('remove','=',NULL);
|
->orWhere('remove','=',NULL);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Where the signature is the same
|
// Where the signalist_duplicatesture is the same
|
||||||
$o->where(function($query)
|
$o->where(function($query)
|
||||||
{
|
{
|
||||||
$query->where('signature','=',$this->signature);
|
$query->where('signature','=',$this->signature);
|
||||||
|
@ -2,54 +2,43 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Traits\ForwardsCalls;
|
||||||
|
use Imagick;
|
||||||
|
|
||||||
class Photo extends Abstracted\Catalog
|
class Photo extends Abstracted\Catalog
|
||||||
{
|
{
|
||||||
protected $table = 'photo';
|
use ForwardsCalls;
|
||||||
|
|
||||||
|
public const config = 'photo';
|
||||||
|
|
||||||
protected static $includeSubSecTime = TRUE;
|
protected static $includeSubSecTime = TRUE;
|
||||||
|
|
||||||
// Imagick Object
|
// Imagick Objectfile_name
|
||||||
private $_o;
|
private ?Imagick $_o;
|
||||||
|
protected array $init = [
|
||||||
|
'creation_date',
|
||||||
|
'gps',
|
||||||
|
'heightwidth',
|
||||||
|
'signature',
|
||||||
|
'software',
|
||||||
|
'subsectime',
|
||||||
|
];
|
||||||
|
|
||||||
// How should the image be rotated, based on the value of orientation
|
// How should the image be rotated, based on the value of orientation
|
||||||
private $_rotate = [
|
private array $_rotate = [
|
||||||
3=>180,
|
3=>180,
|
||||||
6=>90,
|
6=>90,
|
||||||
8=>-90,
|
8=>-90,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getIDLinkAttribute()
|
|
||||||
{
|
|
||||||
return $this->HTMLLinkAttribute($this->id,'p/info');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHtmlImageURL(): string
|
|
||||||
{
|
|
||||||
return sprintf('<img class="p-3" src="%s">',url('p/thumbnail',$this->id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the image, rotated, minus exif data
|
|
||||||
*/
|
|
||||||
public function image()
|
|
||||||
{
|
|
||||||
if (is_null($imo = $this->o()))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (array_key_exists('exif',$imo->getImageProfiles()))
|
|
||||||
$imo->removeImageProfile('exif');
|
|
||||||
|
|
||||||
return $this->rotate($imo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the GPS coordinates
|
* Calculate the GPS coordinates
|
||||||
*/
|
*/
|
||||||
public static function latlon(array $coordinate,$hemisphere)
|
public static function latlon(array $coordinate,string $hemisphere): ?float
|
||||||
{
|
{
|
||||||
if (! $coordinate OR ! $hemisphere)
|
if ((! $coordinate) || (! $hemisphere))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for ($i=0; $i<3; $i++) {
|
for ($i=0; $i<3; $i++) {
|
||||||
@ -67,29 +56,172 @@ class Photo extends Abstracted\Catalog
|
|||||||
|
|
||||||
list($degrees,$minutes,$seconds) = $coordinate;
|
list($degrees,$minutes,$seconds) = $coordinate;
|
||||||
|
|
||||||
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
|
$sign = ($hemisphere === 'W' || $hemisphere === 'S') ? -1 : 1;
|
||||||
|
|
||||||
return round($sign*($degrees+$minutes/60+$seconds/3600),($degrees>100 ? 3 : 4));
|
return round($sign*($degrees+$minutes/60+$seconds/3600),($degrees>100 ? 3 : 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an Imagick object or attribute
|
* Forward calls to Imagick
|
||||||
|
*
|
||||||
|
* @param $method
|
||||||
|
* @param $parameters
|
||||||
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
protected function o($attr=NULL)
|
public function __call($method,$parameters) {
|
||||||
|
if (str_starts_with($method,'Imagick_')) {
|
||||||
|
$method = preg_replace('/^Imagick_/','',$method);
|
||||||
|
|
||||||
|
return $this->o ? $this->forwardCallTo($this->_o,$method,$parameters) : NULL;
|
||||||
|
|
||||||
|
} else
|
||||||
|
return parent::__call($method,$parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __get($key): mixed
|
||||||
{
|
{
|
||||||
if (! file_exists($this->file_path()) OR ! is_readable($this->file_path()))
|
if ($key === 'o') {
|
||||||
return NULL;
|
if (isset($this->_o))
|
||||||
|
return $this->_o;
|
||||||
|
|
||||||
if (is_null($this->_o))
|
if ((!file_exists($this->file_name(FALSE))) || (!is_readable($this->file_name(FALSE))))
|
||||||
$this->_o = new \Imagick($this->file_path());
|
return $this->_o = NULL;
|
||||||
|
|
||||||
return is_null($attr) ? $this->_o : $this->_o->getImageProperty($attr);
|
if (!isset($this->_o))
|
||||||
|
return $this->_o = new Imagick($this->file_name(FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::__get($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ATTRIBUTES */
|
||||||
|
|
||||||
|
public function getFileSignatureAttribute(string $val=NULL): string
|
||||||
|
{
|
||||||
|
return $val ?: $this->getObjectOriginal('file_signature');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeightAttribute(string $val=NULL): ?int
|
||||||
|
{
|
||||||
|
return $val ?: $this->getObjectOriginal('height');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrientationAttribute(int $val=NULL): ?int
|
||||||
|
{
|
||||||
|
return $val ?: $this->getObjectOriginal('orientation');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSignatureAttribute(string $val=NULL): ?string
|
||||||
|
{
|
||||||
|
return $val ?: $this->getObjectOriginal('signature');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWidthAttribute(string $val=NULL): ?int
|
||||||
|
{
|
||||||
|
return $val ?: $this->getObjectOriginal('width');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* METHODS */
|
||||||
|
|
||||||
|
public function custom_init(): void
|
||||||
|
{
|
||||||
|
$this->orientation = $this->getObjectOriginal('orientation');
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($this->isReadable() && $this->o->thumbnailimage(150,150,true)) {
|
||||||
|
$this->o->setImageFormat('jpg');
|
||||||
|
|
||||||
|
$this->thumbnail = $this->o->getImageBlob();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::info(sprintf('Unable to create thumbnail for %s (%s)',$this->id,$e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->thumbnail === FALSE)
|
||||||
|
$this->thumbnail = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObjectOriginal(string $property): mixed
|
||||||
|
{
|
||||||
|
switch ($property) {
|
||||||
|
case 'creation_date':
|
||||||
|
if ($this->Imagick_getImageProperty('exif:DateTimeOriginal') === '0000:00:00 00:00:00'
|
||||||
|
&& $this->Imagick_getImageProperty('exif:DateTime') === '0000:00:00 00:00:00')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
$result = Carbon::create($x=
|
||||||
|
($this->Imagick_getImageProperty('exif:DateTimeOriginal') && ($this->Imagick_getImageProperty('exif:DateTimeOriginal') !== '0000:00:00 00:00:00'))
|
||||||
|
? $this->Imagick_getImageProperty('exif:DateTimeOriginal').$this->Imagick_getImageProperty('exif:OffsetTimeOriginal')
|
||||||
|
: $this->Imagick_getImageProperty('exif:DateTime').$this->Imagick_getImageProperty('exif:OffsetTime'));
|
||||||
|
|
||||||
|
return $result ?: NULL;
|
||||||
|
|
||||||
|
case 'file_signature':
|
||||||
|
return md5_file($this->file_name(FALSE));
|
||||||
|
|
||||||
|
case 'gps_lat':
|
||||||
|
return self::latlon(preg_split('/,\s?/',$this->Imagick_getImageProperty('exif:GPSLatitude')),$this->Imagick_getImageProperty('exif:GPSLatitudeRef'));
|
||||||
|
|
||||||
|
case 'gps_lon':
|
||||||
|
return self::latlon(preg_split('/,\s?/',$this->Imagick_getImageProperty('exif:GPSLongitude')),$this->Imagick_getImageProperty('exif:GPSLongitudeRef'));
|
||||||
|
|
||||||
|
case 'height':
|
||||||
|
return $this->Imagick_getImageHeight();
|
||||||
|
|
||||||
|
case 'identifier':
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
case 'make':
|
||||||
|
return $this->Imagick_getImageProperty('exif:Make');
|
||||||
|
|
||||||
|
case 'model':
|
||||||
|
return $this->Imagick_getImageProperty('exif:Model');
|
||||||
|
|
||||||
|
case 'orientation':
|
||||||
|
return $this->Imagick_getImageOrientation();
|
||||||
|
|
||||||
|
case 'signature':
|
||||||
|
return $this->Imagick_getImageSignature();
|
||||||
|
|
||||||
|
case 'software':
|
||||||
|
return $this->Imagick_getImageProperty('exif:Software');
|
||||||
|
|
||||||
|
case 'subsectime':
|
||||||
|
$this->subsectime = (int)$this->Imagick_getImageProperty('exif:SubSecTimeOriginal');
|
||||||
|
|
||||||
|
// In case of an error.
|
||||||
|
if ($this->subsectime > 32767)
|
||||||
|
$this->subsectime = 32767;
|
||||||
|
|
||||||
|
if ($this->subsectime === FALSE)
|
||||||
|
$this->subsectime = 0;
|
||||||
|
|
||||||
|
return $this->subsectime;
|
||||||
|
|
||||||
|
case 'width':
|
||||||
|
return $this->Imagick_getImageWidth();
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \Exception('To implement: '.$property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the image, rotated
|
||||||
|
*/
|
||||||
|
public function image(): ?string
|
||||||
|
{
|
||||||
|
$imo = clone($this->o);
|
||||||
|
|
||||||
|
return $imo ? $this->rotate($imo) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the orientation of a photo
|
* Display the orientation of a photo
|
||||||
*/
|
*/
|
||||||
public function orientation() {
|
public function orientation(): string
|
||||||
|
{
|
||||||
switch ($this->orientation) {
|
switch ($this->orientation) {
|
||||||
case 1: return 'None!';
|
case 1: return 'None!';
|
||||||
case 3: return 'Upside Down';
|
case 3: return 'Upside Down';
|
||||||
@ -102,118 +234,36 @@ class Photo extends Abstracted\Catalog
|
|||||||
/**
|
/**
|
||||||
* Rotate the image
|
* Rotate the image
|
||||||
*/
|
*/
|
||||||
private function rotate(\Imagick $imo)
|
private function rotate(\Imagick $imo,string $format='jpg'): string
|
||||||
{
|
{
|
||||||
if (array_key_exists($this->orientation,$this->_rotate))
|
if (array_key_exists($this->orientation,$this->_rotate))
|
||||||
$imo->rotateImage(new \ImagickPixel('none'),$this->_rotate[$this->orientation]);
|
$imo->rotateImage(new \ImagickPixel('none'),$this->_rotate[$this->orientation]);
|
||||||
|
|
||||||
$imo->setImageFormat('jpg');
|
$imo->setImageFormat($format);
|
||||||
|
|
||||||
|
if (array_key_exists('exif',$imo->getImageProfiles()))
|
||||||
|
$imo->removeImageProfile('exif');
|
||||||
|
|
||||||
return $imo->getImageBlob();
|
return $imo->getImageBlob();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function property(string $property)
|
|
||||||
{
|
|
||||||
if (! $this->o())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
switch ($property) {
|
|
||||||
case 'creationdate':
|
|
||||||
if ($this->property('exif:DateTimeOriginal') == '0000:00:00 00:00:00'
|
|
||||||
&& $this->property('exif:DateTimeOriginal') == '0000:00:00 00:00:00')
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return strtotime(
|
|
||||||
$this->property('exif:DateTimeOriginal') && $this->property('exif:DateTimeOriginal') != '0000:00:00 00:00:00'
|
|
||||||
? $this->property('exif:DateTimeOriginal')
|
|
||||||
: $this->property('exif:DateTime'));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'height': return $this->_o->getImageHeight();
|
|
||||||
case 'orientation': return $this->_o->getImageOrientation();
|
|
||||||
case 'signature': return $this->_o->getImageSignature();
|
|
||||||
case 'width': return $this->_o->getImageWidth();
|
|
||||||
|
|
||||||
default:
|
|
||||||
return $this->_o->getImageProperty($property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function properties()
|
|
||||||
{
|
|
||||||
return $this->o() ? $this->_o->getImageProperties() : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function setLocation()
|
|
||||||
{
|
|
||||||
$this->gps_lat = static::latlon(preg_split('/,\s?/',$this->property('exif:GPSLatitude')),$this->property('exif:GPSLatitudeRef'));
|
|
||||||
$this->gps_lon = static::latlon(preg_split('/,\s?/',$this->property('exif:GPSLongitude')),$this->property('exif:GPSLongitudeRef'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setMakeModel()
|
|
||||||
{
|
|
||||||
$ma = NULL;
|
|
||||||
|
|
||||||
if ($this->property('exif:Make'))
|
|
||||||
$ma = Make::firstOrCreate([
|
|
||||||
'name'=>$this->property('exif:Make'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$mo = Model::firstOrCreate([
|
|
||||||
'name'=>$this->property('exif:Model') ?: NULL,
|
|
||||||
'make_id'=>$ma ? $ma->id : NULL,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$so = Software::firstOrCreate([
|
|
||||||
'name'=>$this->property('exif:Software') ?: NULL,
|
|
||||||
'model_id'=>$mo->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->software_id = $so->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSubSecTime()
|
|
||||||
{
|
|
||||||
$this->subsectime = (int)$this->property('exif:SubSecTimeOriginal');
|
|
||||||
|
|
||||||
// In case of an error.
|
|
||||||
if ($this->subsectime > 32767)
|
|
||||||
$this->subsectime = 32767;
|
|
||||||
|
|
||||||
if ($this->subsectime === FALSE)
|
|
||||||
$this->subsectime = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setThumbnail()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->thumbnail = exif_thumbnail($this->file_path());
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// @todo Couldnt get the thumbnail, so we should create one.
|
|
||||||
Log::info(sprintf('Unable to create thumbnail for %s (%s)',$this->id,$e->getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->thumbnail === FALSE)
|
|
||||||
$this->thumbnail = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the image's thumbnail
|
* Return the image's thumbnail
|
||||||
*/
|
*/
|
||||||
public function thumbnail($rotate=TRUE)
|
public function thumbnail($rotate=TRUE): ?string
|
||||||
{
|
{
|
||||||
if (! $this->thumbnail) {
|
if (! $this->thumbnail) {
|
||||||
if ($this->isReadable() AND $this->o()->thumbnailimage(200,200,true,false)) {
|
if ($this->isReadable() && $this->o->thumbnailimage(150,150,true)) {
|
||||||
$this->_o->setImageFormat('jpg');
|
$this->o->setImageFormat('jpg');
|
||||||
return $this->_o->getImageBlob();
|
|
||||||
|
return $this->o->getImageBlob();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $rotate OR ! array_key_exists($this->orientation,$this->_rotate) OR ! extension_loaded('imagick'))
|
if ((! $rotate) || (! array_key_exists($this->orientation,$this->_rotate)) || (! extension_loaded('imagick')))
|
||||||
return $this->thumbnail;
|
return $this->thumbnail;
|
||||||
|
|
||||||
$imo = new \Imagick();
|
$imo = new \Imagick();
|
||||||
@ -225,10 +275,9 @@ class Photo extends Abstracted\Catalog
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the extension of the image
|
* Return the extension of the image
|
||||||
* @todo mime-by-ext?
|
|
||||||
*/
|
*/
|
||||||
public function type($mime=FALSE)
|
public function type(bool $mime=FALSE): string
|
||||||
{
|
{
|
||||||
return strtolower($mime ? 'image/jpeg' : pathinfo($this->filename,PATHINFO_EXTENSION));
|
return strtolower($mime ? mime_content_type($this->file_name(FALSE)) : pathinfo($this->filename,PATHINFO_EXTENSION));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
|
||||||
@ -30,12 +31,14 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
|
Route::model('po',Photo::class);
|
||||||
|
|
||||||
// Any photo saved, queue it to be moved.
|
// Any photo saved, queue it to be moved.
|
||||||
Photo::saved(function($photo) {
|
Photo::saved(function($photo) {
|
||||||
if ($photo->scanned AND ! $photo->duplicate AND ! $photo->remove AND ($x=$photo->moveable()) === TRUE) {
|
if ($photo->scanned && (! $photo->duplicate) && (! $photo->remove) && ($x=$photo->moveable()) === TRUE) {
|
||||||
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$photo->id.'|'.serialize($x)));
|
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$photo->id.'|'.serialize($x)));
|
||||||
|
|
||||||
$this->dispatch((new PhotoMove($photo))->onQueue('move'));
|
PhotoMove::dispatch($photo)->onQueue('move');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ trait Type
|
|||||||
{
|
{
|
||||||
private function getModelType(string $type): string
|
private function getModelType(string $type): string
|
||||||
{
|
{
|
||||||
$class = 'App\Models\\'.$type;
|
$class = 'App\Models\\'.ucfirst(strtolower($type));
|
||||||
|
|
||||||
if (! class_exists($class))
|
if (! class_exists($class))
|
||||||
abort(500,sprintf('No class [%s]',$type));
|
abort(500,sprintf('No class [%s]',$type));
|
||||||
|
5
bootstrap/providers.php
Normal file
5
bootstrap/providers.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
];
|
140
composer.json
140
composer.json
@ -1,71 +1,73 @@
|
|||||||
{
|
{
|
||||||
"name": "laravel/laravel",
|
"name": "laravel/laravel",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "The Laravel Framework.",
|
"description": "The Laravel Framework.",
|
||||||
"keywords": ["laravel", "framework"],
|
"keywords": ["laravel", "framework"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"james-heinrich/getid3": "^1.9",
|
"ext-imagick": "*",
|
||||||
"laravel/framework": "^11.0",
|
"ext-pgsql": "*",
|
||||||
"laravel/ui": "^4.5",
|
"james-heinrich/getid3": "^1.9",
|
||||||
"leenooks/laravel": "^11.1",
|
"laravel/framework": "^11.0",
|
||||||
"leenooks/passkey": "^0.2"
|
"laravel/ui": "^4.5",
|
||||||
},
|
"leenooks/laravel": "^11.1",
|
||||||
"require-dev": {
|
"leenooks/passkey": "^0.2"
|
||||||
"barryvdh/laravel-debugbar": "^3.6",
|
},
|
||||||
"fakerphp/faker": "^1.23",
|
"require-dev": {
|
||||||
"laravel/tinker": "^2.9",
|
"barryvdh/laravel-debugbar": "^3.6",
|
||||||
"mockery/mockery": "^1.6",
|
"fakerphp/faker": "^1.23",
|
||||||
"nunomaduro/collision": "^8.0",
|
"laravel/tinker": "^2.9",
|
||||||
"phpunit/phpunit": "^11.0.1",
|
"mockery/mockery": "^1.6",
|
||||||
"spatie/laravel-ignition": "^2.4"
|
"nunomaduro/collision": "^8.0",
|
||||||
},
|
"phpunit/phpunit": "^11.0.1",
|
||||||
"autoload": {
|
"spatie/laravel-ignition": "^2.4"
|
||||||
"psr-4": {
|
},
|
||||||
"App\\": "app/",
|
"autoload": {
|
||||||
"Database\\Factories\\": "database/factories/",
|
"psr-4": {
|
||||||
"Database\\Seeders\\": "database/seeders/"
|
"App\\": "app/",
|
||||||
}
|
"Database\\Factories\\": "database/factories/",
|
||||||
},
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
"autoload-dev": {
|
}
|
||||||
"psr-4": {
|
},
|
||||||
"Tests\\": "tests/"
|
"autoload-dev": {
|
||||||
}
|
"psr-4": {
|
||||||
},
|
"Tests\\": "tests/"
|
||||||
"repositories": {
|
}
|
||||||
"leenooks": {
|
},
|
||||||
"type": "vcs",
|
"repositories": {
|
||||||
"url": "https://gitea.dege.au/laravel/leenooks.git"
|
"leenooks": {
|
||||||
},
|
"type": "vcs",
|
||||||
"passkey": {
|
"url": "https://gitea.dege.au/laravel/leenooks.git"
|
||||||
"type": "vcs",
|
},
|
||||||
"url": "https://gitea.dege.au/laravel/passkey.git"
|
"passkey": {
|
||||||
}
|
"type": "vcs",
|
||||||
},
|
"url": "https://gitea.dege.au/laravel/passkey.git"
|
||||||
"scripts": {
|
}
|
||||||
"post-autoload-dump": [
|
},
|
||||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
"scripts": {
|
||||||
"@php artisan package:discover --ansi"
|
"post-autoload-dump": [
|
||||||
],
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
"post-root-package-install": [
|
"@php artisan package:discover --ansi"
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
],
|
||||||
],
|
"post-root-package-install": [
|
||||||
"post-create-project-cmd": [
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
"@php artisan key:generate --ansi"
|
],
|
||||||
]
|
"post-create-project-cmd": [
|
||||||
},
|
"@php artisan key:generate --ansi"
|
||||||
"extra": {
|
]
|
||||||
"laravel": {
|
},
|
||||||
"dont-discover": []
|
"extra": {
|
||||||
}
|
"laravel": {
|
||||||
},
|
"dont-discover": []
|
||||||
"config": {
|
}
|
||||||
"optimize-autoloader": true,
|
},
|
||||||
"preferred-install": "dist",
|
"config": {
|
||||||
"sort-packages": true
|
"optimize-autoloader": true,
|
||||||
},
|
"preferred-install": "dist",
|
||||||
"minimum-stability": "dev",
|
"sort-packages": true
|
||||||
"prefer-stable": true
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
@ -2,75 +2,81 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Default Filesystem Disk
|
| Default Filesystem Disk
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Here you may specify the default filesystem disk that should be used
|
| Here you may specify the default filesystem disk that should be used
|
||||||
| by the framework. The "local" disk, as well as a variety of cloud
|
| by the framework. The "local" disk, as well as a variety of cloud
|
||||||
| based disks are available to your application for file storage.
|
| based disks are available to your application for file storage.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Filesystem Disks
|
| Filesystem Disks
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Below you may configure as many filesystem disks as necessary, and you
|
| Below you may configure as many filesystem disks as necessary, and you
|
||||||
| may even configure multiple disks for the same driver. Examples for
|
| may even configure multiple disks for the same driver. Examples for
|
||||||
| most supported storage drivers are configured here for reference.
|
| most supported storage drivers are configured here for reference.
|
||||||
|
|
|
|
||||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'disks' => [
|
'disks' => [
|
||||||
|
|
||||||
'local' => [
|
'local' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app'),
|
'root' => storage_path('app'),
|
||||||
'throw' => false,
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
'public' => [
|
'nas' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app/public'),
|
'root' => storage_path('nas'),
|
||||||
'url' => env('APP_URL').'/storage',
|
'throw' => false,
|
||||||
'visibility' => 'public',
|
],
|
||||||
'throw' => false,
|
|
||||||
],
|
|
||||||
|
|
||||||
's3' => [
|
'public' => [
|
||||||
'driver' => 's3',
|
'driver' => 'local',
|
||||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
'root' => storage_path('app/public'),
|
||||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
'url' => env('APP_URL').'/storage',
|
||||||
'region' => env('AWS_DEFAULT_REGION'),
|
'visibility' => 'public',
|
||||||
'bucket' => env('AWS_BUCKET'),
|
'throw' => false,
|
||||||
'url' => env('AWS_URL'),
|
],
|
||||||
'endpoint' => env('AWS_ENDPOINT'),
|
|
||||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
|
||||||
'throw' => false,
|
|
||||||
],
|
|
||||||
|
|
||||||
],
|
's3' => [
|
||||||
|
'driver' => 's3',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION'),
|
||||||
|
'bucket' => env('AWS_BUCKET'),
|
||||||
|
'url' => env('AWS_URL'),
|
||||||
|
'endpoint' => env('AWS_ENDPOINT'),
|
||||||
|
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||||
|
'throw' => false,
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
],
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Symbolic Links
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here you may configure the symbolic links that will be created when the
|
|
||||||
| `storage:link` Artisan command is executed. The array keys should be
|
|
||||||
| the locations of the links and the values should be their targets.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'links' => [
|
/*
|
||||||
public_path('storage') => storage_path('app/public'),
|
|--------------------------------------------------------------------------
|
||||||
],
|
| Symbolic Links
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the symbolic links that will be created when the
|
||||||
|
| `storage:link` Artisan command is executed. The array keys should be
|
||||||
|
| the locations of the links and the values should be their targets.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'links' => [
|
||||||
|
public_path('storage') => storage_path('app/public'),
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'dir'=>'/photos',
|
'dir'=>'Photos',
|
||||||
'import'=>[
|
'import'=>[
|
||||||
'accepted'=>['jpg','jpeg','heic'],
|
'accepted'=>['jpg','jpeg','heic'],
|
||||||
],
|
],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'dir'=>'/videos',
|
'dir'=>'HomeMovies',
|
||||||
'import'=>[
|
'import'=>[
|
||||||
'accepted'=>['m4v','mov','mp4','avi'],
|
'accepted'=>['m4v','mov','mp4','avi'],
|
||||||
],
|
],
|
||||||
|
2560
public/js/maplibre-style.json
Normal file
2560
public/js/maplibre-style.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,14 +20,13 @@
|
|||||||
<span class="pagination justify-content-center">{{ $catalog->links() }}</span>
|
<span class="pagination justify-content-center">{{ $catalog->links() }}</span>
|
||||||
|
|
||||||
<form action="{{ $return }}" method="POST">
|
<form action="{{ $return }}" method="POST">
|
||||||
{{ csrf_field() }}
|
@csrf
|
||||||
|
<input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}">
|
||||||
<input type="hidden" name="type" value="{{ $type }}">
|
<input type="hidden" name="type" value="{{ $type }}">
|
||||||
|
|
||||||
@include('catalog.widgets.duplicates')
|
@include('catalog.widgets.duplicates')
|
||||||
|
|
||||||
<div class="pb-2"><button class="btn btn-sm btn-danger">Confirm Delete</button></div>
|
<div class="pb-2"><button class="btn btn-sm btn-danger">Confirm Delete</button></div>
|
||||||
|
|
||||||
<input type="hidden" name="page" value="{{ $catalog->hasMorePages() ? $catalog->currentPage()+1 : NULL }}">
|
|
||||||
</form>
|
</form>
|
||||||
@else
|
@else
|
||||||
NONE!
|
NONE!
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
<span class="pagination justify-content-center">{{ $catalog->links() }}</span>
|
<span class="pagination justify-content-center">{{ $catalog->links() }}</span>
|
||||||
|
|
||||||
<form action="{{ $return }}" method="POST">
|
<form action="{{ $return }}" method="POST">
|
||||||
{{ csrf_field() }}
|
@csrf
|
||||||
|
|
||||||
<input type="hidden" name="type" value="{{ $type }}">
|
<input type="hidden" name="type" value="{{ $type }}">
|
||||||
|
<input type="hidden" name="page" value="{{ $catalog->currentPage() }}">
|
||||||
|
|
||||||
@include('catalog.widgets.duplicates')
|
@include('catalog.widgets.duplicates')
|
||||||
|
|
||||||
<div class="pb-2"><button class="btn btn-sm btn-primary">Update</button></div>
|
<div class="pb-2"><button class="btn btn-sm btn-primary">Update</button></div>
|
||||||
|
|
||||||
<input type="hidden" name="page" value="{{ $catalog->currentPage() }}">
|
|
||||||
</form>
|
</form>
|
||||||
@else
|
@else
|
||||||
NONE!
|
NONE!
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<table class="table">
|
<table class="table table-light">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-50">Remove</th>
|
<th class="w-50">Remove</th>
|
||||||
@ -6,20 +6,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@php
|
<!-- Remember what we have rendered -->
|
||||||
// Remember what we have rendered
|
@php($rendered = collect())
|
||||||
$rendered = collect();
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
|
<tbody>
|
||||||
@foreach ($catalog as $o)
|
@foreach ($catalog as $o)
|
||||||
@if($rendered->search($o->id)) @continue @endif
|
@continue($rendered->search($o))
|
||||||
@php($rendered->push($o->id))
|
@php($rendered->push($o))
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="items[]" value="{{ $o->id }}">
|
<input type="hidden" name="items[]" value="{{ $o->id }}">
|
||||||
@include($o->type.'.widgets.thumbnail',['o'=>$o])
|
@include($o::config.'.widgets.thumbnail',['o'=>$o,'reference'=>$o->newInstance()])
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@if (! ($d=$o->myduplicates()->get())->count())
|
@if (! ($d=$o->myduplicates()->get())->count())
|
||||||
@ -30,15 +28,15 @@
|
|||||||
|
|
||||||
@else
|
@else
|
||||||
@foreach($d as $item)
|
@foreach($d as $item)
|
||||||
@if($rendered->search($item->id)) @continue @endif
|
@continue($rendered->search($item))
|
||||||
@php($rendered->push($item->id))
|
@php($rendered->push($item))
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="items[]" value="{{ $item->id }}">
|
<input type="hidden" name="items[]" value="{{ $item->id }}">
|
||||||
@include($item->type.'.widgets.thumbnail',['o'=>$item])
|
@include($item::config.'.widgets.thumbnail',['o'=>$item,'reference'=>$o])
|
||||||
</td>
|
</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
1
resources/views/components/info.blade.php
Normal file
1
resources/views/components/info.blade.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href="{{ url('p/info',$id) }}" target="{{ $id }}">{{ $id }}</a>
|
3
resources/views/components/thumbnail.blade.php
Normal file
3
resources/views/components/thumbnail.blade.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<a href="{{ url('p/view',$id) }}" target="{{ $id }}">
|
||||||
|
<img class="p-3" src="{{ url('p/thumbnail',$id) }}">
|
||||||
|
</a>
|
@ -1,117 +1,137 @@
|
|||||||
@extends('adminlte::layouts.app')
|
@extends('adminlte::layouts.app')
|
||||||
|
|
||||||
@section('htmlheader_title')
|
@section('htmlheader_title')
|
||||||
Photo - {{ $o->id }}
|
Photo - {{ $po->id }}
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('contentheader_title')
|
@section('contentheader_title')
|
||||||
Photo #{{ $o->id }}
|
Photo #{{ $po->id }}
|
||||||
@endsection
|
@endsection
|
||||||
@section('contentheader_description')
|
@section('contentheader_description')
|
||||||
@if(! $o->scanned)<button class="btn btn-sm btn-info">TO SCAN</button>@endif
|
|
||||||
@if($o->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif
|
|
||||||
@if($o->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif
|
|
||||||
@if($o->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif
|
|
||||||
@endsection
|
@endsection
|
||||||
@section('page_title')
|
@section('page_title')
|
||||||
#{{ $o->id }}
|
#{{ $po->id }}
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('main-content')
|
@section('main-content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<a href="{{ url('p/view',$o->id) }}">{!! $o->getHtmlImageURL() !!}</a>
|
<x-thumbnail :id="$po->id"/>
|
||||||
|
|
||||||
<span class="pagination justify-content-center">
|
<div class="pagination justify-content-center">
|
||||||
<nav>
|
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<li class="page-item @if(! $x=$o->previous())disabled @endif" aria-disabled="@if(! $x)true @else false @endif" aria-label="« Previous">
|
<li class="page-item @disabled(! $x=$po->previous())">
|
||||||
<a class="page-link" href="{{ $x ? url('p/info',$x->id) : '#' }}"><<</a>
|
<a class="page-link" href="{{ $x ? url('p/info',$x->id) : '#' }}"><<</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="page-item active" aria-current="page"><span class="page-link">{{ $o->id }}</span></li>
|
<li class="page-item active" aria-current="page">
|
||||||
|
<span class="page-link">{{ $po->id }}</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="page-item @if(! $x=$o->next())disabled @endif" aria-disabled="@if(! $x)true @else false @endif" aria-label="« Previous">
|
<li class="page-item @disabled(! $x=$po->next())">
|
||||||
<a class="page-link" href="{{ $x ? url('p/info',$x->id) : '#' }}">>></a>
|
<a class="page-link" href="{{ $x ? url('p/info',$x->id) : '#' }}">>></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</div>
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
<div class="dl-horizontal">
|
<div class="card">
|
||||||
<dt>Signature</dt><dd>{{ $o->signature(TRUE) }}</dd>
|
<div class="card-body">
|
||||||
<dt>Filename</dt><dd>{{ $o->filename }}<dd>
|
<div class="float-right">
|
||||||
|
@if(! $po->scanned)<button class="btn btn-sm btn-info">TO SCAN</button>@endif
|
||||||
|
@if($po->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif
|
||||||
|
@if($po->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif
|
||||||
|
@if($po->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif
|
||||||
|
</div>
|
||||||
|
<div class="dl-horizontal">
|
||||||
|
<dt>Signature</dt><dd>{{ $po->signature(TRUE) }}</dd>
|
||||||
|
<dt>Filename</dt><dd>{{ $po->filename }}<dd>
|
||||||
|
|
||||||
@if ($o->shouldMove())
|
@if($po->shouldMove())
|
||||||
<dt>NEW Filename</dt><dd>{{ $o->file_name() }}<dd>
|
<dt>NEW Filename</dt><dd>{{ $po->file_name() }}<dd>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<dt>Size</dt><dd>{{ $o->file_size() }}<dd>
|
<dt>Size</dt><dd>{{ number_format($po->file_size,0) }}<dd>
|
||||||
<dt>Dimensions</dt><dd>{{ $o->dimensions }} @ {{ $o->orientation }}<dd>
|
<dt>Dimensions</dt><dd>{{ $po->dimensions }} @ {{ $po->orientation }}<dd>
|
||||||
<hr>
|
<hr>
|
||||||
<dt>Date Taken</dt><dd>{{ $o->date_taken() }}<dd>
|
<dt>Date Taken</dt><dd>{{ $po->created?->format('Y-m-d H:i:s') }}<dd>
|
||||||
<dt>Camera</dt><dd>{{ $o->device() }}<dd>
|
|
||||||
<hr>
|
@if($po->scanned)
|
||||||
<dt>Location</dt>
|
<dt>Camera</dt><dd>{{ $po->device}}<dd>
|
||||||
<dd>
|
<hr>
|
||||||
@if($o->gps() == 'UNKNOWN')
|
<dt>Location</dt>
|
||||||
UNKNOWN
|
<dd>
|
||||||
@else
|
@if(! $po->gps)
|
||||||
<div id="map" style="width: 400px; height: 300px"></div>
|
UNKNOWN
|
||||||
@endif
|
@else
|
||||||
</dd>
|
<div id="map" class="w-100" style="height: 30em;"></div>
|
||||||
<hr>
|
@endif
|
||||||
<dt>Exif Data</dt><dd>
|
</dd>
|
||||||
<table>
|
@endif
|
||||||
@foreach ($o->properties() as $k => $v)
|
|
||||||
<tr><th>{{ $k }}<><td>{{ $v }}<td></tr>
|
@if($x=$po->Imagick_getImageProperties())
|
||||||
@endforeach
|
<hr>
|
||||||
</table>
|
|
||||||
</dd>
|
<dt>Exif Data</dt><dd>
|
||||||
<hr>
|
<table class="table table-sm table-striped">
|
||||||
@if(($x=$o->myduplicates()->get())->count())
|
@foreach($x as $k => $v)
|
||||||
<dt>Duplicates</dt>
|
<tr>
|
||||||
<dd>
|
<th>{{ $k }}</th><td>{{ $v }}<td>
|
||||||
@foreach($x as $oo)
|
</tr>
|
||||||
@if(! $loop->first)| @endif
|
@endforeach
|
||||||
{!! $oo->id_link !!}
|
</table>
|
||||||
@endforeach
|
</dd>
|
||||||
</dd>
|
@endif
|
||||||
@endif
|
|
||||||
|
@if(($x=$po->myduplicates()->get())->count())
|
||||||
|
<hr>
|
||||||
|
<dt>Duplicates</dt>
|
||||||
|
<dd>
|
||||||
|
@foreach($x as $oo)
|
||||||
|
@if(! $loop->first)| @endif
|
||||||
|
<x-info :id="$oo->id"/>
|
||||||
|
@endforeach
|
||||||
|
</dd>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($o->remove)
|
@if($po->remove)
|
||||||
<form action="{{ url('p/undelete',$o->id) }}" method="POST">
|
<form action="{{ url('p/undelete',$po->id) }}" method="POST">
|
||||||
<button class="btn btn-primary">Undelete</button>
|
<button class="btn btn-primary">Undelete</button>
|
||||||
|
|
||||||
@else
|
@else
|
||||||
<form action="{{ url('p/delete',$o->id) }}" method="POST">
|
<form action="{{ url('p/delete',$po->id) }}" method="POST">
|
||||||
<button class="btn btn-danger">Delete</button>
|
<button class="btn btn-danger">Delete</button>
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
{{ csrf_field() }}
|
@csrf
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('page-scripts')
|
@section('page-scripts')
|
||||||
@if($o->gps() !== 'UNKNOWN')
|
@if($po->gps)
|
||||||
@js('//maps.google.com/maps/api/js?sensor=false')
|
<script type="text/javascript" src="//unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
|
||||||
|
<link type='text/css' href="//unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel='stylesheet'>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var myLatLng = {lat: {{ $o->gps_lat }}, lng: {{ $o->gps_lon }}};
|
const key = 'hspQjLANaPwdHUrvUcsf';
|
||||||
var map = new google.maps.Map(document.getElementById("map"), {
|
|
||||||
zoom: 16,
|
var map = new maplibregl.Map({
|
||||||
center: myLatLng,
|
container: 'map', // container id
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
style: '/js/maplibre-style.json', // style URL
|
||||||
});
|
center: [{{ $po->gps_lon }}, {{ $po->gps_lat }}], // starting position [lng, lat]
|
||||||
var marker = new google.maps.Marker({
|
zoom: 12 // starting zoom
|
||||||
map: map,
|
|
||||||
position: myLatLng,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let marker = new maplibregl.Marker()
|
||||||
|
.setLngLat([{{ $po->gps_lon }}, {{ $po->gps_lat }}])
|
||||||
|
.addTo(map);
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
@append
|
@append
|
@ -1,5 +1,4 @@
|
|||||||
<?php $data = [
|
<?php $data = [
|
||||||
'ID'=>['id','idlink'],
|
|
||||||
'Signature'=>['signature','signature'],
|
'Signature'=>['signature','signature'],
|
||||||
'File Signature'=>['file_signature','file_signature'],
|
'File Signature'=>['file_signature','file_signature'],
|
||||||
'Date Created'=>['created','created'],
|
'Date Created'=>['created','created'],
|
||||||
@ -15,27 +14,29 @@
|
|||||||
<div class="card card-widget">
|
<div class="card card-widget">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div class="user-block">
|
<div class="user-block">
|
||||||
<i class="float-left fa fa-2x fa-camera"></i><span class="username"><a href="{{ url('p/info',$o->id) }}">#{{ $o->id }} - {{ \Illuminate\Support\Str::limit($o->filename,12).\Illuminate\Support\Str::substr($o->filename,-16) }}</a></span>
|
<i class="fas fa-2x fa-camera float-left"></i><span class="username"><a href="{{ url('p/info',$o->id) }}">#{{ $o->id }} - {{ Str::limit($o->filename,12).Str::substr($o->filename,-16) }}</a></span>
|
||||||
<span class="description">{{ $o->created ? $o->created->toDateTimeString() : '-' }} [{{ $o->device() }}]</span>
|
<span class="description">{{ $o->created ? $o->created->toDateTimeString() : '-' }} @if($o->device)[{{ $o->device }}]@else <small><strong>[No Device Info]</strong></small> @endif</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.user-block -->
|
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-minus"></i></button>
|
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-minus"></i></button>
|
||||||
<button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fa fa-times"></i></button>
|
<button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fa fa-times"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.card-tools -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- /.card-body -->
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a href="{{ url('p/view',$o->id) }}" target="{{ $o->id }}">{!! $o->getHtmlImageURL() !!}</a>
|
<x-thumbnail :id="$o->id"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- /.card-body -->
|
|
||||||
<div class="card-footer card-comments">
|
<div class="card-footer card-comments">
|
||||||
<table class="table table-striped table-sm table-hover">
|
<table class="table table-sm table-striped">
|
||||||
|
<tr><th>ID</th><td><x-info :id="$o->id"/></td></tr>
|
||||||
|
|
||||||
@foreach($data as $k=>$v)
|
@foreach($data as $k=>$v)
|
||||||
<tr><th>{{$k}}</th><td>{!! $o->{$v[1]} !!}</td></tr>
|
<tr @class(['bg-success'=>($reference->exists && $reference->{$v[1]} === $o->{$v[1]})])>
|
||||||
|
<th>{{$k}}</th>
|
||||||
|
<td>{!! $o->{$v[1]} !!}</td>
|
||||||
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,8 +15,8 @@ Route::get('/p/duplicates/{id?}',[PhotoController::class,'duplicates'])
|
|||||||
Route::get('/v/duplicates/{id?}',[VideoController::class,'duplicates'])
|
Route::get('/v/duplicates/{id?}',[VideoController::class,'duplicates'])
|
||||||
->where('id','[0-9]+');
|
->where('id','[0-9]+');
|
||||||
|
|
||||||
Route::get('/p/info/{o}',[PhotoController::class,'info'])
|
Route::view('/p/info/{po}','photo.view')
|
||||||
->where('o','[0-9]+');
|
->where('po','[0-9]+');
|
||||||
Route::get('/v/info/{o}',[VideoController::class,'info'])
|
Route::get('/v/info/{o}',[VideoController::class,'info'])
|
||||||
->where('o','[0-9]+');
|
->where('o','[0-9]+');
|
||||||
Route::get('/p/thumbnail/{o}',[PhotoController::class,'thumbnail'])
|
Route::get('/p/thumbnail/{o}',[PhotoController::class,'thumbnail'])
|
||||||
|
Loading…
Reference in New Issue
Block a user