You've already forked lubo_comment_query
抽象封装简化
This commit is contained in:
@ -4,8 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Programs;
|
||||
use App\Models\ProgramVideos;
|
||||
use App\Util\TimeUtil;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Util\ProgramVideoUtil;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Carbon;
|
||||
@ -125,29 +124,7 @@ class ProgramVideoConstructController extends BaseController
|
||||
}
|
||||
$each_time = $request->post("each_time");
|
||||
$each_time_sec = Carbon::createFromFormat("H:i:s", $each_time)->secondsSinceMidnight();
|
||||
/**
|
||||
* @var $program_videos ProgramVideos[]
|
||||
*/
|
||||
$program_videos = ProgramVideos::query()
|
||||
->where("video_bvid", "=", $program_video->video_bvid)
|
||||
->where("id", "!=", $program_video->id)
|
||||
->where(function (Builder $query) use ($program_video) {
|
||||
$query->where("created_at", ">", $program_video->created_at)->orWhere("created_at", "=", null);
|
||||
})
|
||||
->get();
|
||||
$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;
|
||||
}
|
||||
$video->created_at = TimeUtil::calculate_program_time(
|
||||
$base_time,
|
||||
$video->start_sec,
|
||||
($video->start_part - 1) * $each_time_sec
|
||||
);
|
||||
$video->update();
|
||||
}
|
||||
ProgramVideoUtil::fix_created_at_by_manual($program_video, $each_time_sec);
|
||||
return redirect(route("program.construct.list"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user