From fe155525a392296741816ff399cf84f589b57828 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 27 Dec 2019 13:32:42 +1100 Subject: [PATCH] Minor fixes --- app/Console/Commands/CatalogMove.php | 3 ++- app/Console/Commands/CatalogScan.php | 2 +- app/Http/Controllers/VideoController.php | 5 +++++ app/Models/Abstracted/Catalog.php | 1 + app/Models/Photo.php | 11 +++++++---- app/Models/Video.php | 11 +++++++---- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/CatalogMove.php b/app/Console/Commands/CatalogMove.php index 945057d..b79cd31 100644 --- a/app/Console/Commands/CatalogMove.php +++ b/app/Console/Commands/CatalogMove.php @@ -45,8 +45,9 @@ class CatalogMove extends Command continue; } + $x = NULL; if (! $o->scanned OR $o->duplicate OR $o->remove OR ($x=$o->moveable()) !== TRUE) { - $this->warn(sprintf('Ignoring [%s]...',$o->file_path())); + $this->warn(sprintf('Ignoring (%s)[%s]... [%s]',$o->id,$o->file_path(),$x)); continue; } diff --git a/app/Console/Commands/CatalogScan.php b/app/Console/Commands/CatalogScan.php index d5340f1..290c0cd 100644 --- a/app/Console/Commands/CatalogScan.php +++ b/app/Console/Commands/CatalogScan.php @@ -48,7 +48,7 @@ class CatalogScan extends Command $o->setThumbnail(); // If this is a duplicate - $x = $class::whereIN('id',$o->list_duplicate())->get(); + $x = $o->duplicates()->get(); if (count($x)) { foreach ($x as $oo) { // And that photo is not marked as a duplicate diff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.php index 95cd0b4..49fa45a 100644 --- a/app/Http/Controllers/VideoController.php +++ b/app/Http/Controllers/VideoController.php @@ -49,6 +49,11 @@ class VideoController extends Controller if ($o->remove AND $request->input('remove.'.$id)) $this->dispatch((new VideoDelete($o))->onQueue('delete')); + + elseif (! $o->remove) { + $o->remove = TRUE; + $o->save(); + } } return redirect()->action('VideoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL); diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index e83a86c..4d0f028 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -263,6 +263,7 @@ abstract class Catalog extends Model /** * Return the object type * @return string + * @deprecated Use objecttype() */ public function getTypeAttribute(): string { diff --git a/app/Models/Photo.php b/app/Models/Photo.php index 9608427..ed44198 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -181,13 +181,16 @@ class Photo extends Abstracted\Catalog public function setMakeModel() { - $ma = Make::firstOrCreate([ - 'name'=>$this->property('exif:Make') ?: NULL, - ]); + $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->id, + 'make_id'=>$ma ? $ma->id : NULL, ]); $so = Software::firstOrCreate([ diff --git a/app/Models/Video.php b/app/Models/Video.php index f247421..b9dd2f2 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -143,13 +143,16 @@ class Video extends Abstracted\Catalog public function setMakeModel() { - $ma = Make::firstOrCreate([ - 'name'=>$this->property('make') ?: NULL, - ]); + $ma = NULL; + + if ($this->property('make')) + $ma = Make::firstOrCreate([ + 'name'=>$this->property('make'), + ]); $mo = Model::firstOrCreate([ 'name'=>$this->property('model') ?: NULL, - 'make_id'=>$ma->id, + 'make_id'=>$ma ? $ma->id : NULL, ]); $so = Software::firstOrCreate([