2016-07-04 06:00:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
use App\Http\Requests;
|
|
|
|
use App\Model\Video;
|
|
|
|
use App\Jobs\VideoDelete;
|
2018-01-09 21:10:14 +00:00
|
|
|
use App\Helpers\VideoStream;
|
2016-07-04 06:00:33 +00:00
|
|
|
|
|
|
|
class VideoController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($id)
|
|
|
|
{
|
|
|
|
$po = Video::notRemove()->findOrFail($id);
|
|
|
|
|
|
|
|
if ($po)
|
|
|
|
{
|
|
|
|
$po->remove = TRUE;
|
|
|
|
$po->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->action('VideoController@info',[$id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deletes()
|
|
|
|
{
|
|
|
|
return view('video.deletereview',['videos'=>Video::where('remove',1)->paginate(2)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deletesUpdate(Request $request)
|
|
|
|
{
|
|
|
|
foreach ($request->input('video') as $id)
|
|
|
|
{
|
|
|
|
$video = Video::findOrFail($id);
|
|
|
|
|
|
|
|
if ($video->remove AND $request->input('remove.'.$id))
|
|
|
|
$this->dispatch((new VideoDelete($video))->onQueue('delete'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->action('VideoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function duplicates($id=NULL)
|
|
|
|
{
|
|
|
|
return view('video.duplicates',['videos'=>is_null($id) ? Video::notRemove()->where('duplicate',1)->paginate(1) : Video::where('id',$id)->paginate(1)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function duplicatesUpdate(Request $request)
|
|
|
|
{
|
|
|
|
foreach ($request->input('video') as $id)
|
|
|
|
{
|
|
|
|
$po = Video::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('VideoController@duplicates','?page='.$request->input('page'));
|
|
|
|
}
|
|
|
|
public function info($id)
|
|
|
|
{
|
|
|
|
return view('video.view', ['video'=> Video::findOrFail($id)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undelete($id)
|
|
|
|
{
|
|
|
|
$po = Video::findOrFail($id);
|
|
|
|
|
|
|
|
if ($po)
|
|
|
|
{
|
|
|
|
$po->remove = NULL;
|
|
|
|
$po->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->action('VideoController@info',[$id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id)
|
|
|
|
{
|
2018-01-09 21:10:14 +00:00
|
|
|
(new VideoStream(Video::findOrFail($id)->file_path()))->start();
|
2016-07-04 06:00:33 +00:00
|
|
|
}
|
|
|
|
}
|