Minor code cleanup

This commit is contained in:
Deon George 2019-12-15 23:59:46 +11:00
parent 49933382f3
commit c176ba9c94
3 changed files with 54 additions and 59 deletions

View File

@ -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)

View File

@ -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();
}
}

View File

@ -20,7 +20,7 @@
</li>
<li class="nav-item">
<a href="{{ url('p/deletes') }}" class="nav-link @if(preg_match('#^p/deletes$/'.'#',request()->path())) active @endif">
<a href="{{ url('p/deletes') }}" class="nav-link @if(preg_match('#^p/deletes$#',request()->path())) active @endif">
<i class="fa fa-calendar nav-icon"></i> <p>Delete</p>
<span class="badge badge-danger right">{{ \App\Models\Photo::where('remove',TRUE)->count() }}</span>
</a>
@ -42,7 +42,7 @@
</li>
<li class="nav-item">
<a href="{{ url('v/deletes') }}" class="nav-link @if(preg_match('#^v/deletes$/'.'#',request()->path())) active @endif">
<a href="{{ url('v/deletes') }}" class="nav-link @if(preg_match('#^v/deletes$#',request()->path())) active @endif">
<i class="fa fa-calendar nav-icon"></i> <p>Delete</p>
<span class="badge badge-danger right">{{ \App\Models\Video::where('remove',TRUE)->count() }}</span>
</a>