节目视频编辑时,额外验证start_part和stop_part

This commit is contained in:
Jerry Yan 2022-08-17 14:05:27 +08:00
parent b7d425d5cf
commit aef72d9252
Signed by: q792602257
GPG Key ID: D070F653AF6C0004

View File

@ -29,10 +29,10 @@ class ProgramVideoConstructController extends BaseController
$request->validate([
"video_bvid" => ["required"],
"start_part" => ["required", "int"],
"stop_part" => ["required", "int"],
"stop_part" => ["required", "int", "gte:start_part"],
"start_time" => ["required", "date_format:H:i:s"],
"stop_time" => ["required", "date_format:H:i:s"],
"created_at" => ["required", "date"],
"created_at" => ["date"],
]);
$program_video = new ProgramVideos();
$createPayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]);
@ -42,17 +42,17 @@ class ProgramVideoConstructController extends BaseController
$file = $request->file("start_image");
$path = $file->store("lubo_file");
$full_path = Storage::url($path);
// $program_video->start_image = str_replace("jerryyan.top", "jerryyan.net", $full_path);
$program_video->start_image = $full_path;
}
if ($request->hasFile("stop_image")) {
$file = $request->file("stop_image");
$path = $file->store("lubo_file");
$full_path = Storage::url($path);
// $program_video->stop_image = str_replace("jerryyan.top", "jerryyan.net", $full_path);
$program_video->stop_image = $full_path;
}
if ($request->has("created_at")) {
$program_video->created_at = $request->post("created_at");
}
$program->video_pivots()->save($program_video);
return redirect(route("program.construct.video.list", [
"program"=>$program_video->program_id
@ -68,27 +68,27 @@ class ProgramVideoConstructController extends BaseController
public function submit(Request $request, ProgramVideos $program_video) {
$request->validate([
"start_part" => ["required", "int"],
"stop_part" => ["required", "int"],
"stop_part" => ["required", "int", "gte:start_part"],
"start_time" => ["required", "date_format:H:i:s"],
"stop_time" => ["required", "date_format:H:i:s"],
"created_at" => ["required", "date"],
"created_at" => ["date"],
]);
$updatePayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]);
if ($request->hasFile("start_image")) {
$file = $request->file("start_image");
$path = $file->store("lubo_file");
$full_path = Storage::url($path);
// $program_video->start_image = str_replace("jerryyan.top", "jerryyan.net", $full_path);
$program_video->start_image = $full_path;
}
if ($request->hasFile("stop_image")) {
$file = $request->file("stop_image");
$path = $file->store("lubo_file");
$full_path = Storage::url($path);
// $program_video->stop_image = str_replace("jerryyan.top", "jerryyan.net", $full_path);
$program_video->stop_image = $full_path;
}
if ($request->has("created_at")) {
$program_video->created_at = $request->post("created_at");
}
$program_video->update($updatePayload);
/**
* @var $program Programs