You've already forked lubo_comment_query
新款导入节目单,自动匹配时间(需提前导入分P信息)
This commit is contained in:
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Programs;
|
||||
use App\Models\ProgramVideos;
|
||||
use App\Util\TimeUtil;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
@ -134,21 +135,17 @@ class ProgramVideoConstructController extends BaseController
|
||||
$query->where("created_at", ">", $program_video->created_at)->orWhere("created_at", "=", null);
|
||||
})
|
||||
->get();
|
||||
/**
|
||||
* @var $created_at Carbon
|
||||
*/
|
||||
$created_at = $program_video->created_at;
|
||||
$base_time = $created_at->subSeconds($program_video->start_sec)->subSeconds(($program_video->start_part - 1) * $each_time_sec);
|
||||
foreach ($program_videos as $video) {
|
||||
if ($video->id === $program_video->id) {
|
||||
continue;
|
||||
}
|
||||
$time = $base_time->copy()->addSeconds(($video->start_part - 1) * $each_time_sec)->addSeconds($video->start_sec);
|
||||
if ($time->second > 30) {
|
||||
$time->addMinute();
|
||||
}
|
||||
$time->seconds(0);
|
||||
$video->created_at = $time;
|
||||
$video->created_at = TimeUtil::calculate_program_time(
|
||||
$base_time,
|
||||
$video->start_sec,
|
||||
($video->start_part - 1) * $each_time_sec
|
||||
);
|
||||
$video->update();
|
||||
}
|
||||
return redirect(route("program.construct.list"));
|
||||
|
Reference in New Issue
Block a user