photo/app/Http/Controllers/PhotoController.php

78 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2016-06-22 05:49:20 +00:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
2019-11-09 02:52:04 +00:00
use App\Models\Photo;
use App\Traits\Multimedia;
2016-06-22 05:49:20 +00:00
class PhotoController extends Controller
{
use Multimedia;
public function delete(Photo $o)
2019-12-15 12:34:42 +00:00
{
$o->remove = TRUE;
$o->save();
return redirect()
->back();
2019-12-15 12:34:42 +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',[
'catalog'=>is_null($id)
? Photo::where('remove',1)
->with(['software.model.make'])
->orderBy('id')
->paginate($request->input('list',self::list_deletes))
: Photo::where('id',$id)
->paginate(1),
2019-12-15 00:30:29 +00:00
'return'=>url('p/deletes'),
'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
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',[
'catalog'=>is_null($id)
? Photo::duplicates()
->with(['software.model.make'])
->paginate($request->input('list',self::list_duplicates))
: Photo::where('id',$id)
->paginate(1),
2019-12-15 00:30:29 +00:00
'return'=>url('p/duplicates'),
'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
public function thumbnail(Photo $o)
2019-12-15 12:34:42 +00:00
{
return response($o->thumbnail())
->header('Content-Type','image/jpeg');
2019-12-15 12:34:42 +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();
return redirect()
->back();
2019-12-15 12:34:42 +00:00
}
/**
* Render the photo to the browser
*
* @param Photo $o
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Foundation\Application|\Illuminate\Http\Response
*/
public function view(Photo $o)
2019-12-15 12:34:42 +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
}