创建时,填写bvid

This commit is contained in:
Jerry Yan 2022-08-04 09:46:43 +08:00
parent b72e766eca
commit 548ff4323f
3 changed files with 14 additions and 7 deletions

View File

@ -25,6 +25,7 @@ class ProgramVideoConstructController extends BaseController
public function create(Request $request, Programs $program) { public function create(Request $request, Programs $program) {
$request->validate([ $request->validate([
"video_bvid" => ["required"],
"start_part" => ["required", "int"], "start_part" => ["required", "int"],
"stop_part" => ["required", "int"], "stop_part" => ["required", "int"],
"start_time" => ["required", "date_format:H:i:s"], "start_time" => ["required", "date_format:H:i:s"],
@ -34,6 +35,7 @@ class ProgramVideoConstructController extends BaseController
$program_video = new ProgramVideos(); $program_video = new ProgramVideos();
$createPayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]); $createPayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]);
$program_video->fill($createPayload); $program_video->fill($createPayload);
$program_video->video_bvid = $request->post("video_bvid");
if ($request->hasFile("start_image")) { if ($request->hasFile("start_image")) {
$file = $request->file("start_image"); $file = $request->file("start_image");
$path = $file->store("lubo_file"); $path = $file->store("lubo_file");

View File

@ -8,7 +8,7 @@ use Illuminate\Support\Carbon;
class ProgramVideos extends Model class ProgramVideos extends Model
{ {
protected $fillable = ["start_part", "start_time", "stop_part", "stop_time"]; protected $fillable = ["video_bvid", "start_part", "start_time", "stop_part", "stop_time"];
protected $dateFormat = 'U'; protected $dateFormat = 'U';
public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {

View File

@ -11,15 +11,15 @@
<input type="hidden" name="id" value="{{$program_video->id}}"> <input type="hidden" name="id" value="{{$program_video->id}}">
<label class="block my-2"> <label class="block my-2">
BVID BVID
<input class="form-input border-0 border-b-2 w-full" @if($program_video->video_bvid) disabled @endif type="text" name="video_bvid" value="{{$program_video->video_bvid}}"> <input class="form-input border-0 border-b-2 w-full" @if($program_video->video_bvid) disabled @endif type="text" name="video_bvid" value="{{ old("video_bvid", $program_video->video_bvid) }}">
</label> </label>
<label class="block my-2"> <label class="block my-2">
开始P数 开始P数
<input class="form-input border-0 border-b-2 w-full" type="number" name="start_part" value="{{$program_video->start_part}}"> <input class="form-input border-0 border-b-2 w-full" type="number" name="start_part" value="{{ old("start_part", $program_video->start_part) }}">
</label> </label>
<label class="block my-2"> <label class="block my-2">
开始时间 开始时间
<input class="form-input border-0 border-b-2 w-full" step="1" type="time" name="start_time" value="{{$program_video->start_time}}"> <input class="form-input border-0 border-b-2 w-full" step="1" type="time" name="start_time" value="{{ old("start_time", $program_video->start_time) }}">
</label> </label>
<label class="block my-2"> <label class="block my-2">
开始图像 开始图像
@ -30,15 +30,15 @@
</label> </label>
<label class="block my-2"> <label class="block my-2">
节目开打时间 节目开打时间
<input class="form-input border-0 border-b-2 w-full" type="datetime-local" step="1" name="created_at" value="{{$program_video->created_at}}"> <input class="form-input border-0 border-b-2 w-full" type="datetime-local" step="1" name="created_at" value="{{ old("created_at", $program_video->created_at) }}">
</label> </label>
<label class="block my-2"> <label class="block my-2">
结束P数 结束P数
<input class="form-input border-0 border-b-2 w-full" type="number" name="stop_part" value="{{$program_video->stop_part}}"> <input class="form-input border-0 border-b-2 w-full" type="number" name="stop_part" value="{{ old("stop_part", $program_video->stop_part) }}">
</label> </label>
<label class="block my-2"> <label class="block my-2">
结束时间 结束时间
<input class="form-input border-0 border-b-2 w-full" step="1" type="time" name="stop_time" value="{{$program_video->stop_time}}"> <input class="form-input border-0 border-b-2 w-full" step="1" type="time" name="stop_time" value="{{ old("stop_time", $program_video->stop_time) }}">
</label> </label>
<label class="block my-2"> <label class="block my-2">
结束图像 结束图像
@ -47,6 +47,11 @@
@endif @endif
<input class="form-input border-0 border-b-2 w-full" type="file" name="stop_image"> <input class="form-input border-0 border-b-2 w-full" type="file" name="stop_image">
</label> </label>
@if($errors->any())
@foreach ($errors->all() as $error)
<div class="bg-red-600 text-white">错误:{{ $error }}</div>
@endforeach
@endif
<div class="block my-2 text-center"> <div class="block my-2 text-center">
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit"> <input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit">
</div> </div>