2016-06-22 05:49:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Response;
|
2016-06-29 23:32:57 +00:00
|
|
|
use Illuminate\Http\Request;
|
2016-06-22 05:49:20 +00:00
|
|
|
|
|
|
|
use App\Http\Requests;
|
|
|
|
use App\Model\Photo;
|
2016-06-30 06:01:12 +00:00
|
|
|
use App\Jobs\PhotoDelete;
|
2016-06-22 05:49:20 +00:00
|
|
|
|
|
|
|
class PhotoController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
|
|
|
|
2016-06-29 10:49:02 +00:00
|
|
|
public function delete($id)
|
|
|
|
{
|
|
|
|
$po = Photo::notRemove()->findOrFail($id);
|
|
|
|
|
|
|
|
if ($po)
|
|
|
|
{
|
|
|
|
$po->remove = TRUE;
|
|
|
|
$po->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->action('PhotoController@info',[$id]);
|
|
|
|
}
|
|
|
|
|
2018-01-11 12:59:53 +00:00
|
|
|
public function deletes($id=NULL)
|
2016-06-30 06:01:12 +00:00
|
|
|
{
|
2019-11-08 10:43:36 +00:00
|
|
|
return view('catalog.deletereview',['return'=>url('/p/deletes'),'catalog'=>is_null($id) ? Photo::where('remove',1)->paginate(50) : Photo::where('id',$id)->paginate(1)]);
|
2016-06-30 06:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function deletesUpdate(Request $request)
|
|
|
|
{
|
2018-01-11 12:59:53 +00:00
|
|
|
foreach ($request->input('remove') as $id=>$k)
|
2016-06-30 06:01:12 +00:00
|
|
|
{
|
2018-01-11 12:59:53 +00:00
|
|
|
$o = Photo::findOrFail($id);
|
2016-06-30 06:01:12 +00:00
|
|
|
|
2018-01-11 12:59:53 +00:00
|
|
|
if ($o->remove AND $request->input('remove.'.$id))
|
|
|
|
$this->dispatch((new PhotoDelete($o))->onQueue('delete'));
|
2016-06-30 06:01:12 +00:00
|
|
|
}
|
|
|
|
|
2016-06-30 11:34:18 +00:00
|
|
|
return redirect()->action('PhotoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL);
|
2016-06-30 06:01:12 +00:00
|
|
|
}
|
|
|
|
|
2016-06-29 23:32:57 +00:00
|
|
|
public function duplicates($id=NULL)
|
|
|
|
{
|
2019-11-08 10:43:36 +00:00
|
|
|
return view('catalog.duplicatereview',['return'=>url('/p/duplicates'),'catalog'=>is_null($id) ? Photo::notRemove()->where('duplicate',1)->paginate(50) : Photo::where('id',$id)->paginate(1)]);
|
2016-06-29 23:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function duplicatesUpdate(Request $request)
|
|
|
|
{
|
2019-11-08 10:43:36 +00:00
|
|
|
foreach ($request->input('items') as $id)
|
2016-06-29 23:32:57 +00:00
|
|
|
{
|
|
|
|
$po = Photo::findOrFail($id);
|
|
|
|
|
|
|
|
// Set if duplicate
|
|
|
|
$po->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL;
|
|
|
|
|
|
|
|
// Set if flag
|
|
|
|
$po->flag = $request->input('flag.'.$id) ? 1 : NULL;
|
|
|
|
|
|
|
|
// Set if delete
|
|
|
|
$po->remove = $request->input('remove.'.$id) ? 1 : NULL;
|
|
|
|
|
|
|
|
$po->isDirty() AND $po->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->action('PhotoController@duplicates','?page='.$request->input('page'));
|
|
|
|
}
|
2018-01-09 21:10:14 +00:00
|
|
|
|
2016-06-22 05:49:20 +00:00
|
|
|
public function info($id)
|
|
|
|
{
|
|
|
|
return view('photo.view', ['photo'=> Photo::findOrFail($id)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function thumbnail($id)
|
|
|
|
{
|
2016-06-29 10:49:02 +00:00
|
|
|
return response(Photo::findOrFail($id)->thumbnail(TRUE))->header('Content-Type','image/jpeg');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undelete($id)
|
|
|
|
{
|
|
|
|
$po = Photo::findOrFail($id);
|
|
|
|
|
|
|
|
if ($po)
|
|
|
|
{
|
|
|
|
$po->remove = NULL;
|
|
|
|
$po->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->action('PhotoController@info',[$id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id)
|
|
|
|
{
|
|
|
|
return response(Photo::findOrFail($id)->image())->header('Content-Type','image/jpeg');
|
2016-06-22 05:49:20 +00:00
|
|
|
}
|
|
|
|
}
|