2016-06-22 05:49:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2024-10-01 01:44:26 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
2024-09-30 12:56:08 +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-10-01 01:44:26 +00:00
|
|
|
public function deletes(Request $request,$id=NULL)
|
2019-12-15 12:34:42 +00:00
|
|
|
{
|
2019-12-15 00:30:29 +00:00
|
|
|
return view('catalog.deletereview',[
|
2024-09-30 12:56:08 +00:00
|
|
|
'catalog'=>is_null($id)
|
|
|
|
? Photo::where('remove',1)
|
|
|
|
->with(['software.model.make'])
|
2024-10-01 01:44:26 +00:00
|
|
|
->paginate($request->input('list',self::list_deletes))
|
2024-09-30 12:56:08 +00:00
|
|
|
: 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
|
|
|
|
2024-10-01 01:44:26 +00:00
|
|
|
public function duplicates(Request $request,$id=NULL)
|
2019-12-15 12:34:42 +00:00
|
|
|
{
|
2019-11-09 02:52:04 +00:00
|
|
|
return view('catalog.duplicatereview',[
|
2024-09-30 12:56:08 +00:00
|
|
|
'catalog'=>is_null($id)
|
|
|
|
? Photo::duplicates()
|
|
|
|
->with(['software.model.make'])
|
2024-10-01 01:44:26 +00:00
|
|
|
->paginate($request->input('list',self::list_duplicates))
|
2024-09-30 12:56:08 +00:00
|
|
|
: 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
|
|
|
}
|