photo/app/Http/Controllers/PhotoController.php

65 lines
1.4 KiB
PHP
Raw Normal View History

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;
use App\Traits\Multimedia;
2016-06-22 05:49:20 +00:00
class PhotoController extends Controller
{
use Multimedia;
2019-12-15 10:08:33 +00:00
protected $list_duplicates = 20;
protected $list_deletes = 50;
public function delete(Photo $o)
2019-12-15 12:34:42 +00:00
{
$o->remove = TRUE;
$o->save();
return redirect()->action('PhotoController@info',[$o->id]);
2019-12-15 12:34:42 +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',[
'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'),
'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',[
'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'),
'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
2019-12-15 12:34:42 +00:00
public function info(Photo $o)
{
2019-12-14 11:29:54 +00:00
return view('photo.view',['o'=>$o]);
2019-12-15 12:34:42 +00:00
}
2016-06-22 05:49:20 +00:00
public function thumbnail(Photo $o)
2019-12-15 12:34:42 +00:00
{
return response($o->thumbnail(TRUE))
->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();
2019-12-15 12:59:46 +00:00
return redirect()->action('PhotoController@info',[$o->id]);
2019-12-15 12:34:42 +00:00
}
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
}