2016-06-22 05:49:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2019-11-09 02:52:04 +00:00
|
|
|
use App\Models\Photo;
|
2020-01-04 13:28:00 +00:00
|
|
|
use App\Traits\Multimedia;
|
2016-06-22 05:49:20 +00:00
|
|
|
|
|
|
|
class PhotoController extends Controller
|
|
|
|
{
|
2020-01-04 13:28:00 +00:00
|
|
|
use Multimedia;
|
|
|
|
|
2019-12-15 10:08:33 +00:00
|
|
|
protected $list_duplicates = 20;
|
|
|
|
protected $list_deletes = 50;
|
|
|
|
|
2020-01-04 13:28:00 +00:00
|
|
|
public function delete(Photo $o)
|
2019-12-15 12:34:42 +00:00
|
|
|
{
|
2020-01-04 13:28:00 +00:00
|
|
|
$o->remove = TRUE;
|
|
|
|
$o->save();
|
2016-06-29 10:49:02 +00:00
|
|
|
|
2020-01-04 13:28:00 +00:00
|
|
|
return redirect()->action('PhotoController@info',[$o->id]);
|
2019-12-15 12:34:42 +00:00
|
|
|
}
|
2016-06-29 10:49:02 +00:00
|
|
|
|
2019-12-15 12:34:42 +00:00
|
|
|
public function deletes($id=NULL)
|
|
|
|
{
|
2019-12-15 00:30:29 +00:00
|
|
|
return view('catalog.deletereview',[
|
2020-01-04 13:28:00 +00:00
|
|
|
'catalog'=>is_null($id) ? Photo::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Photo::where('id',$id)->paginate(1),
|
2019-12-15 00:30:29 +00:00
|
|
|
'return'=>url('p/deletes'),
|
2020-01-04 13:28:00 +00:00
|
|
|
'type'=>'photo',
|
2019-12-15 00:30:29 +00:00
|
|
|
]);
|
2019-12-15 12:34:42 +00:00
|
|
|
}
|
2016-06-30 06:01:12 +00:00
|
|
|
|
2019-12-15 12:34:42 +00:00
|
|
|
public function duplicates($id=NULL)
|
|
|
|
{
|
2019-11-09 02:52:04 +00:00
|
|
|
return view('catalog.duplicatereview',[
|
2020-01-04 13:28:00 +00:00
|
|
|
'catalog'=>is_null($id) ? Photo::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Photo::where('id',$id)->paginate(1),
|
2019-12-15 00:30:29 +00:00
|
|
|
'return'=>url('p/duplicates'),
|
2020-01-04 13:28:00 +00:00
|
|
|
'type'=>'photo',
|
2019-11-09 02:52:04 +00:00
|
|
|
]);
|
2019-12-15 12:34:42 +00:00
|
|
|
}
|
2016-06-29 23:32:57 +00:00
|
|
|
|
2020-01-04 13:28:00 +00:00
|
|
|
public function thumbnail(Photo $o)
|
2019-12-15 12:34:42 +00:00
|
|
|
{
|
2024-08-31 12:23:07 +00:00
|
|
|
return response($o->thumbnail())
|
2020-01-04 13:28:00 +00:00
|
|
|
->header('Content-Type','image/jpeg');
|
2019-12-15 12:34:42 +00:00
|
|
|
}
|
2016-06-29 10:49:02 +00:00
|
|
|
|
2019-12-15 12:59:46 +00:00
|
|
|
public function undelete(Photo $o)
|
2019-12-15 12:34:42 +00:00
|
|
|
{
|
2019-12-15 12:59:46 +00:00
|
|
|
$o->remove = NULL;
|
|
|
|
$o->save();
|
2016-06-29 10:49:02 +00:00
|
|
|
|
2024-08-31 12:23:07 +00:00
|
|
|
return redirect()
|
|
|
|
->action('PhotoController@info',[$o->id]);
|
2019-12-15 12:34:42 +00:00
|
|
|
}
|
2016-06-29 10:49:02 +00:00
|
|
|
|
2024-08-31 12:23:07 +00:00
|
|
|
/**
|
|
|
|
* Render the photo to the browser
|
|
|
|
*
|
|
|
|
* @param Photo $o
|
|
|
|
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Foundation\Application|\Illuminate\Http\Response
|
|
|
|
*/
|
2020-01-04 13:28:00 +00:00
|
|
|
public function view(Photo $o)
|
2019-12-15 12:34:42 +00:00
|
|
|
{
|
2020-01-04 13:28:00 +00:00
|
|
|
return response($o->image())
|
|
|
|
->header('Content-Type','image/jpeg');
|
2019-12-15 12:34:42 +00:00
|
|
|
}
|
2019-11-09 02:52:04 +00:00
|
|
|
}
|