From c176ba9c94643fc69262def5018c4927853df11b Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 15 Dec 2019 23:59:46 +1100 Subject: [PATCH] Minor code cleanup --- app/Http/Controllers/PhotoController.php | 31 ++++---- app/Http/Controllers/VideoController.php | 78 +++++++++---------- .../layouts/partials/sidebarmenu.blade.php | 4 +- 3 files changed, 54 insertions(+), 59 deletions(-) diff --git a/app/Http/Controllers/PhotoController.php b/app/Http/Controllers/PhotoController.php index c5cf1d4..9b0d49c 100644 --- a/app/Http/Controllers/PhotoController.php +++ b/app/Http/Controllers/PhotoController.php @@ -24,12 +24,12 @@ class PhotoController extends Controller public function delete($id) { - $po = Photo::notRemove()->findOrFail($id); + $o = Photo::notRemove()->findOrFail($id); - if ($po) + if ($o) { - $po->remove = TRUE; - $po->save(); + $o->remove = TRUE; + $o->save(); } return redirect()->action('PhotoController@info',[$id]); @@ -68,18 +68,18 @@ class PhotoController extends Controller { foreach ($request->input('items') as $id) { - $po = Photo::findOrFail($id); + $o = Photo::findOrFail($id); // Set if duplicate - $po->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL; + $o->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL; // Set if flag - $po->flag = $request->input('flag.'.$id) ? 1 : NULL; + $o->flag = $request->input('flag.'.$id) ? 1 : NULL; // Set if delete - $po->remove = $request->input('remove.'.$id) ? 1 : NULL; + $o->remove = $request->input('remove.'.$id) ? 1 : NULL; - $po->save(); + $o->save(); } return redirect()->action('PhotoController@duplicates','?page='.$request->input('page')); @@ -95,17 +95,12 @@ class PhotoController extends Controller return response(Photo::findOrFail($id)->thumbnail(TRUE))->header('Content-Type','image/jpeg'); } - public function undelete($id) + public function undelete(Photo $o) { - $po = Photo::findOrFail($id); + $o->remove = NULL; + $o->save(); - if ($po) - { - $po->remove = NULL; - $po->save(); - } - - return redirect()->action('PhotoController@info',[$id]); + return redirect()->action('PhotoController@info',[$o->id]); } public function view($id) diff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.php index 19f9ba8..95cd0b4 100644 --- a/app/Http/Controllers/VideoController.php +++ b/app/Http/Controllers/VideoController.php @@ -22,81 +22,81 @@ class VideoController extends Controller public function delete($id) { - $po = Video::notRemove()->findOrFail($id); + $o = Video::notRemove()->findOrFail($id); - if ($po) - { - $po->remove = TRUE; - $po->save(); - } + if ($o) + { + $o->remove = TRUE; + $o->save(); + } - return redirect()->action('VideoController@info',[$id]); + return redirect()->action('VideoController@info',[$id]); } public function deletes($id=NULL) { - return view('catalog.deletereview',['return'=>url('v/deletes'),'catalog'=>is_null($id) ? Video::where('remove',1)->paginate(50) : Video::where('id',$id)->paginate(1)]); + return view('catalog.deletereview',[ + 'return'=>url('v/deletes'), + 'catalog'=>is_null($id) ? Video::where('remove',1)->paginate(50) : Video::where('id',$id)->paginate(1) + ]); } public function deletesUpdate(Request $request) { - foreach ($request->input('remove') as $k=>$id) - { - $o = Video::findOrFail($k); + foreach ($request->input('remove') as $id=>$k) + { + $o = Video::findOrFail($id); - if ($o->remove AND $request->input('remove.'.$k)) - $this->dispatch((new VideoDelete($o))->onQueue('delete')); - } + if ($o->remove AND $request->input('remove.'.$id)) + $this->dispatch((new VideoDelete($o))->onQueue('delete')); + } - return redirect()->action('VideoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL); + return redirect()->action('VideoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL); } public function duplicates($id=NULL) { - return view('catalog.duplicatereview',['return'=>url('/v/duplicates'),'catalog'=>is_null($id) ? Video::notRemove()->where('duplicate',1)->paginate(50) : Video::where('id',$id)->paginate(1)]); + return view('catalog.duplicatereview',[ + 'return'=>url('v/duplicates'), + 'catalog'=>is_null($id) ? Video::notRemove()->where('duplicate',1)->paginate(50) : Video::where('id',$id)->paginate(1)]); } public function duplicatesUpdate(Request $request) { - foreach ($request->input('items') as $id) - { - $po = Video::findOrFail($id); + foreach ($request->input('items') as $id) + { + $o = Video::findOrFail($id); - // Set if duplicate - $po->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL; + // Set if duplicate + $o->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL; - // Set if flag - $po->flag = $request->input('flag.'.$id) ? 1 : NULL; + // Set if flag + $o->flag = $request->input('flag.'.$id) ? 1 : NULL; - // Set if delete - $po->remove = $request->input('remove.'.$id) ? 1 : NULL; + // Set if delete + $o->remove = $request->input('remove.'.$id) ? 1 : NULL; - $po->isDirty() AND $po->save(); - } + $o->save(); + } - return redirect()->action('VideoController@duplicates','?page='.$request->input('page')); + return redirect()->action('VideoController@duplicates','?page='.$request->input('page')); } public function info(Video $o) { - return view('video.view', ['o'=>$o]); + return view('video.view',['o'=>$o]); } - public function undelete($id) + public function undelete(Video $o) { - $po = Video::findOrFail($id); + $o->remove = NULL; + $o->save(); - if ($po) - { - $po->remove = NULL; - $po->save(); - } - - return redirect()->action('VideoController@info',[$id]); + return redirect()->action('VideoController@info',[$o->id]); } public function view($id) { - (new VideoStream(Video::findOrFail($id)->file_path()))->start(); + (new VideoStream(Video::findOrFail($id)->file_path()))->start(); } } \ No newline at end of file diff --git a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php index 1b562ca..1fe1fc0 100644 --- a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php +++ b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php @@ -20,7 +20,7 @@