From 7bd4bad94143da98f7679e857c9b90236ac93faa Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 6 Jan 2020 20:01:04 +1100 Subject: [PATCH] Bug fixes --- app/Console/Commands/CatalogAutoDelete.php | 5 +---- app/Http/Controllers/VideoController.php | 4 ++-- app/Models/Abstracted/Catalog.php | 8 ++++++-- app/Models/Video.php | 2 +- app/Traits/Multimedia.php | 18 ++++++++++++------ resources/views/video/view.blade.php | 2 +- .../views/video/widgets/thumbnail.blade.php | 2 +- .../views/widgets/summary/boxes.blade.php | 4 ++-- 8 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/Console/Commands/CatalogAutoDelete.php b/app/Console/Commands/CatalogAutoDelete.php index 3ebe49b..7c6b099 100644 --- a/app/Console/Commands/CatalogAutoDelete.php +++ b/app/Console/Commands/CatalogAutoDelete.php @@ -2,13 +2,10 @@ namespace App\Console\Commands; -use App\Jobs\PhotoMove; -use App\Jobs\VideoMove; use Illuminate\Console\Command; use Illuminate\Foundation\Bus\DispatchesJobs; -use App\Jobs\PhotoDelete; -use App\Models\Photo; +use App\Jobs\{PhotoDelete,VideoDelete}; use App\Traits\Type; class CatalogAutoDelete extends Command diff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.php index c56a663..3844a17 100644 --- a/app/Http/Controllers/VideoController.php +++ b/app/Http/Controllers/VideoController.php @@ -36,7 +36,7 @@ class VideoController extends Controller return view('catalog.deletereview',[ 'catalog'=>is_null($id) ? Video::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Video::where('id',$id)->paginate(1), 'return'=>url('v/deletes'), - 'type'=>'photo', + 'type'=>'video', ]); } @@ -45,7 +45,7 @@ class VideoController extends Controller return view('catalog.duplicatereview',[ 'catalog'=>is_null($id) ? Video::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Video::where('id',$id)->paginate(1), 'return'=>url('v/duplicates'), - 'type'=>'photo', + 'type'=>'video', ]); } diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index 3dd62ac..d8cb82e 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -132,7 +132,11 @@ abstract class Catalog extends Model return $query->where(function($query) { $query->where('duplicate','<>',TRUE) - ->orWhere('duplicate','=',NULL); + ->orWhere('duplicate','=',NULL) + ->orWhere(function($q) { + $q->where('duplicate','=',TRUE) + ->where('ignore_duplicate','=',TRUE); + }); }); } @@ -490,7 +494,7 @@ abstract class Catalog extends Model public function setDateCreated() { - $this->created = $this->property('creationdate'); + $this->created = $this->property('creationdate') ?: NULL; } public function setHeightWidth() diff --git a/app/Models/Video.php b/app/Models/Video.php index 78e3f17..52d8692 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -126,7 +126,7 @@ class Video extends Abstracted\Catalog public function setDateCreated() { - $this->created = strtotime($this->property('creationdate')); + $this->created = $this->property('creationdate') ? strtotime($this->property('creationdate')) : NULL; } public function setLocation() diff --git a/app/Traits/Multimedia.php b/app/Traits/Multimedia.php index 6c191ea..b9cc75b 100644 --- a/app/Traits/Multimedia.php +++ b/app/Traits/Multimedia.php @@ -2,6 +2,7 @@ namespace App\Traits; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; @@ -20,7 +21,7 @@ trait Multimedia { switch (strtolower($type)) { case 'photo': return 'PhotoController'; - case 'video': return 'Videoontroller'; + case 'video': return 'VideoController'; default: abort(500,'Type not handled?'); } } @@ -50,7 +51,14 @@ trait Multimedia private function updatePostItems(Request $request,string $class,bool $delete=FALSE) { foreach ($request->input('items') as $id) { - $o = $class::findOrFail($id); + try { + $o = $class::findOrFail($id); + } catch (ModelNotFoundException $e) { + Log::alert('Object not found: '.$id); + continue; + } catch (\Exception $e) { + dd($e); + } // Set if duplicate $o->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL; @@ -63,9 +71,7 @@ trait Multimedia // Set if delete if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) { - Log::info(sprintf('Dispatching delete for [%s]',$o->id)); - - switch ($class) { + switch (strtolower($request->input('type'))) { case 'photo': $this->dispatch((new PhotoDelete($o))->onQueue('delete')); Log::info(sprintf('Dispatching delete for [%s]',$o->id)); @@ -77,7 +83,7 @@ trait Multimedia break; default: - Log::info(sprintf('Ignoring delete for [%s] - not configured.',$o->id)); + Log::info(sprintf('Ignoring delete for [%s] - not configured (%s).',$o->id,$class)); } } else { diff --git a/resources/views/video/view.blade.php b/resources/views/video/view.blade.php index 9715246..07d98b7 100644 --- a/resources/views/video/view.blade.php +++ b/resources/views/video/view.blade.php @@ -20,7 +20,7 @@ @section('main-content')
- {!! $o->getHtmlImageURL() !!} + {!! $o->getHtmlImageURL() !!}