diff --git a/app/Http/Controllers/PhotoController.php b/app/Http/Controllers/PhotoController.php index 51bc3cb..84345a2 100644 --- a/app/Http/Controllers/PhotoController.php +++ b/app/Http/Controllers/PhotoController.php @@ -9,21 +9,24 @@ class PhotoController extends Controller { use Multimedia; - protected $list_duplicates = 20; - protected $list_deletes = 50; - public function delete(Photo $o) { $o->remove = TRUE; $o->save(); - return redirect()->action('PhotoController@info',[$o->id]); + return redirect() + ->action('PhotoController@info',[$o->id]); } public function deletes($id=NULL) { return view('catalog.deletereview',[ - 'catalog'=>is_null($id) ? Photo::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Photo::where('id',$id)->paginate(1), + 'catalog'=>is_null($id) + ? Photo::where('remove',1) + ->with(['software.model.make']) + ->paginate(self::list_deletes) + : Photo::where('id',$id) + ->paginate(1), 'return'=>url('p/deletes'), 'type'=>'photo', ]); @@ -32,7 +35,12 @@ class PhotoController extends Controller public function duplicates($id=NULL) { return view('catalog.duplicatereview',[ - 'catalog'=>is_null($id) ? Photo::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Photo::where('id',$id)->paginate(1), + 'catalog'=>is_null($id) + ? Photo::duplicates() + ->with(['software.model.make']) + ->paginate(self::list_duplicates) + : Photo::where('id',$id) + ->paginate(1), 'return'=>url('p/duplicates'), 'type'=>'photo', ]); diff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.php index 0581448..502499e 100644 --- a/app/Http/Controllers/VideoController.php +++ b/app/Http/Controllers/VideoController.php @@ -10,21 +10,24 @@ class VideoController extends Controller { use Multimedia; - protected $list_duplicates = 20; - protected $list_deletes = 50; - public function delete(Video $o) { $o->remove = TRUE; $o->save(); - return redirect()->action('VideoController@info',[$o->id]); + return redirect() + ->action('VideoController@info',[$o->id]); } public function deletes($id=NULL) { 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), + 'catalog'=>is_null($id) + ? Video::where('remove',1) + ->with(['software.model.make']) + ->paginate(self::list_deletes) + : Video::where('id',$id) + ->paginate(1), 'return'=>url('v/deletes'), 'type'=>'video', ]); @@ -33,7 +36,12 @@ class VideoController extends Controller public function duplicates($id=NULL) { return view('catalog.duplicatereview',[ - 'catalog'=>is_null($id) ? Video::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Video::where('id',$id)->paginate(1), + 'catalog'=>is_null($id) + ? Video::duplicates() + ->with(['software.model.make']) + ->paginate(self::list_duplicates) + : Video::where('id',$id) + ->paginate(1), 'return'=>url('v/duplicates'), 'type'=>'video', ]); @@ -44,7 +52,8 @@ class VideoController extends Controller $o->remove = NULL; $o->save(); - return redirect()->action('VideoController@info',[$o->id]); + return redirect() + ->action('VideoController@info',[$o->id]); } public function view(Video $o) diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index 9b37d0d..4d18e74 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -322,67 +322,6 @@ abstract class Catalog extends Model return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/'); } - /** - * Return HTML Checkbox for duplicate - * @deprecated use a component - */ - public function getDuplicateCheckboxAttribute() - { - return $this->HTMLCheckbox('duplicate',$this->id,$this->duplicate); - } - - /** - * Return HTML Checkbox for flagged - * @deprecated use a component - */ - public function getFlagCheckboxAttribute() - { - return $this->HTMLCheckbox('flag',$this->id,$this->flag); - } - - /** - * Return HTML Checkbox for ignore - * @deprecated use a component - */ - public function getIgnoreCheckboxAttribute() - { - return $this->HTMLCheckbox('ignore_duplicate',$this->id,$this->ignore_duplicate); - } - - /** - * @deprecated use a component - */ - public function getDuplicateTextAttribute() - { - return $this->TextTrueFalse($this->duplicate); - } - - /** - * @deprecated use a component - */ - public function getFlagTextAttribute() - { - return $this->TextTrueFalse($this->flag); - } - - /** - * Return HTML Checkbox for remove - * @deprecated use a component - */ - public function getRemoveCheckboxAttribute() - { - return $this->HTMLCheckbox('remove',$this->id,$this->remove); - } - - /** - * Return an HTML checkbox - * @deprecated use a component - */ - protected function HTMLCheckbox($name,$id,$value) - { - return sprintf('',$name,$id,$value ? ' checked="checked"' : ''); - } - /** * Set values from the media object * @@ -558,12 +497,6 @@ abstract class Catalog extends Model return $this->filename !== $this->file_name(); } - /** @deprecated is this really needed? */ - private function TextTrueFalse($value): string - { - return $value ? 'TRUE' : 'FALSE'; - } - /** * Find duplicate images based on some attributes of the current image */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 3b8efa2..8c72363 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,6 +5,7 @@ namespace App\Providers; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Illuminate\Foundation\Bus\DispatchesJobs; +use Illuminate\Pagination\Paginator; use App\Models\{Photo,Video}; @@ -31,5 +32,7 @@ class AppServiceProvider extends ServiceProvider { Route::model('po',Photo::class); Route::model('vo',Video::class); + + Paginator::useBootstrapFour(); } } \ No newline at end of file diff --git a/app/Traits/Multimedia.php b/app/Traits/Multimedia.php index b9cc75b..e6bbf17 100644 --- a/app/Traits/Multimedia.php +++ b/app/Traits/Multimedia.php @@ -17,6 +17,9 @@ trait Multimedia { use Type; + protected const list_duplicates = 20; + protected const list_deletes = 50; + private function controller(string $type): string { switch (strtolower($type)) { @@ -31,10 +34,11 @@ trait Multimedia $class = $this->getModelType($request->input('type')); $this->updatePostItems($request,$class,TRUE); - return redirect()->action( - sprintf('%s@deletes',$this->controller($request->input('type'))), - sprintf('?page=%s',$request->input('page')) - ); + return redirect() + ->action( + sprintf('%s@deletes',$this->controller($request->input('type'))), + sprintf('?page=%s',$request->input('page')) + ); } public function duplicatesUpdate(Request $request) @@ -42,10 +46,11 @@ trait Multimedia $class = $this->getModelType($request->input('type')); $this->updatePostItems($request,$class); - return redirect()->action( - sprintf('%s@duplicates',$this->controller($request->input('type'))), - sprintf('?page=%s',$request->input('page')) - ); + return redirect() + ->action( + sprintf('%s@duplicates',$this->controller($request->input('type'))), + sprintf('?page=%s',$request->input('page')) + ); } private function updatePostItems(Request $request,string $class,bool $delete=FALSE) @@ -53,9 +58,11 @@ trait Multimedia foreach ($request->input('items') as $id) { try { $o = $class::findOrFail($id); + } catch (ModelNotFoundException $e) { Log::alert('Object not found: '.$id); continue; + } catch (\Exception $e) { dd($e); } @@ -70,7 +77,7 @@ trait Multimedia $o->flag = $request->input('flag.'.$id) ? 1 : NULL; // Set if delete - if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) { + if ($delete && $o->remove && ($request->input('remove.'.$id) ? 1 : NULL)) { switch (strtolower($request->input('type'))) { case 'photo': $this->dispatch((new PhotoDelete($o))->onQueue('delete')); diff --git a/resources/views/catalog/deletereview.blade.php b/resources/views/catalog/deletereview.blade.php index 7825e89..9dbd838 100644 --- a/resources/views/catalog/deletereview.blade.php +++ b/resources/views/catalog/deletereview.blade.php @@ -17,14 +17,17 @@ @section('main-content')