mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-15 11:07:53 -04:00
79 lines
3.0 KiB
PHP
79 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\StudioPlus\Http\Controllers;
|
|
|
|
use Illuminate\Contracts\Support\Renderable;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\StudioPlus\Imports\StudioPlusVideoOttImport;
|
|
use Brian2694\Toastr\Facades\Toastr;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
class ProcessVideosController extends Controller
|
|
{
|
|
public function videoTypes()
|
|
{
|
|
|
|
\Modules\StudioPlus\Entities\StudioPlusVideo::whereNull('studio_plus_video_type_id')->chunkById(100, function ($videos) {
|
|
foreach ($videos as $key => $video) {
|
|
if(is_array($video->types)){
|
|
if(count($video->types) == 0 && $video->is_short == 0){
|
|
$video->studio_plus_video_type_id = 1;
|
|
} else if(in_array("VIDEO BASED ON A JOB", $video->types) && $video->is_short == 0){
|
|
$video->studio_plus_video_type_id = 2;
|
|
} else if(in_array("REACH OUT", $video->types) && $video->is_short == 0){
|
|
$video->studio_plus_video_type_id = 3;
|
|
} else if(in_array("SPONSORED PRODUCT", $video->types)){
|
|
$video->studio_plus_video_type_id = 4;
|
|
} else if(count($video->types) == 0 && $video->is_short == 1){
|
|
$video->studio_plus_video_type_id = 5;
|
|
} else if(in_array("VIDEO BASED ON A JOB", $video->types) && $video->is_short == 1){
|
|
$video->studio_plus_video_type_id = 6;
|
|
}
|
|
$video->update();
|
|
}
|
|
}
|
|
});
|
|
|
|
dd('Successfully Process New Video Types');
|
|
}
|
|
|
|
public function cleanUpTracks()
|
|
{
|
|
|
|
$duplicates = \Modules\StudioPlus\Entities\StudioPlusVideoStatusTrack::select(\DB::raw('COUNT(*) as `count`'),'id','studio_plus_video_id','name','created_at')
|
|
->where('name','Published')
|
|
->groupBy('studio_plus_video_id', 'name')
|
|
->orderBy('created_at','desc')
|
|
->havingRaw('COUNT(*) > 1')
|
|
->limit(1000)->get();
|
|
|
|
foreach ($duplicates as $key => $duplicate) {
|
|
\Modules\StudioPlus\Entities\StudioPlusVideoStatusTrack::where('studio_plus_video_id', $duplicate->studio_plus_video_id)->where('name', $duplicate->name)->where('id', '!=', $duplicate->id)->delete();
|
|
}
|
|
|
|
dd('Successfully Cleanup Tracks '.count($duplicates));
|
|
}
|
|
|
|
public function ott()
|
|
{
|
|
return view('studioplus::import_ott');
|
|
}
|
|
|
|
public function processOtt(Request $request)
|
|
{
|
|
$request->validate([
|
|
'file' => 'required|mimes:csv,txt,xls,xlsx'
|
|
]);
|
|
ini_set('max_execution_time', 0);
|
|
try {
|
|
Excel::import(new StudioPlusVideoOttImport, $request->file('file'));
|
|
Toastr::success('Ott Details Imported Successfully.', __('common.success'));
|
|
return back();
|
|
} catch (\Exception $e) {
|
|
Toastr::error($e->getMessage());
|
|
return back();
|
|
}
|
|
}
|
|
}
|