You've already forked lubo_comment_query
							
							建设相关的路由,及大部分提交的验证,及视频对应的真·节目单
This commit is contained in:
		| @@ -9,7 +9,7 @@ use Illuminate\Routing\Controller as BaseController; | ||||
| 
 | ||||
| class ProgramAppendConstructController extends BaseController | ||||
| { | ||||
|     public function construct(Request $request, Programs $program) { | ||||
|     public function index(Request $request, Programs $program) { | ||||
|         return view("program.construct.append.index", [ | ||||
|             "program" => $program, | ||||
|             "appends" => $program->appends, | ||||
| @@ -28,6 +28,11 @@ class ProgramAppendConstructController extends BaseController | ||||
|     } | ||||
| 
 | ||||
|     public function create(Request $request, Programs $program) { | ||||
|         $request->validate([ | ||||
|             "name" => ["required_without:foo:is_original"], | ||||
|             "from" => ["required"], | ||||
|             "price" => ["required", "numeric"], | ||||
|         ]); | ||||
|         $createPayload = $request->only(["name", "from", "price", "append"]); | ||||
|         $append = $program->appends()->create($createPayload); | ||||
|         $append->is_original = $request->post("is_original", 0); | ||||
|   | ||||
| @@ -3,12 +3,13 @@ | ||||
| namespace App\Http\Controllers; | ||||
| 
 | ||||
| use App\Models\Programs; | ||||
| use App\Models\ProgramVideos; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Routing\Controller as BaseController; | ||||
| 
 | ||||
| class ProgramConstructController extends BaseController | ||||
| { | ||||
|     public function construct(Request $request) { | ||||
|     public function index(Request $request) { | ||||
|         $status = $request->get("status", "0"); | ||||
|         $query = Programs::query()->with(["appends", "video_pivots.video"])->where("status", $status, 0)->orderByDesc("created_at"); | ||||
|         $programs = $query->paginate(10)->withQueryString();; | ||||
| @@ -17,6 +18,67 @@ class ProgramConstructController extends BaseController | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     public function add(Request $request) { | ||||
|         return view("program.construct.create", [ | ||||
|             "program"=>new Programs() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     public function create(Request $request) { | ||||
|         $request->validate([ | ||||
|             "name" => ["required"] | ||||
|         ]); | ||||
|         $program = new Programs(); | ||||
|         $createPayload = $request->only(["name", "difficulty", "desc"]); | ||||
|         $program->fill($createPayload); | ||||
|         $program->status = $request->post("status", 0); | ||||
|         $program->save(); | ||||
|         return redirect(route("program.construct.edit", ["program"=>$program->id])); | ||||
|     } | ||||
| 
 | ||||
|     public function batch_add(Request $request) { | ||||
|         return view("program.construct.batch_add"); | ||||
|     } | ||||
| 
 | ||||
|     public function batch_create(Request $request) { | ||||
|         $request->validate([ | ||||
|             'bvid' => ['required'], | ||||
|             'content' => ['required'], | ||||
|         ]); | ||||
|         $bvid = $request->post("bvid"); | ||||
|         $content = $request->post("content"); | ||||
|         $count = ProgramVideos::query()->where("video_bvid", "=", $bvid)->count(); | ||||
|         if ($count > 0) { | ||||
|             return view("program.construct.batch_add", [ | ||||
|                 "content" => $content, | ||||
|                 "bvid" => $bvid, | ||||
|                 "message" => "该BVID下已有{$count}个节目关联,请手动添加", | ||||
|             ]); | ||||
|         } | ||||
|         $regex = "/^p(?P<part>\d{1,2})[-# _:,)]+(?P<time>(0?1[::])?(\d{1,3}[::])\d{1,2})?[ :]?(?P<content>.+)$/i"; | ||||
|         foreach (explode("\n", $content) as $line) { | ||||
|             $match = []; | ||||
|             $match_count = preg_match($regex, $line, $match); | ||||
|             if ($match_count > 0) { | ||||
|                 $time = $match["time"]; | ||||
|                 $time = str_replace(":", ":", $time); | ||||
|                 while (substr_count($time, ":") < 2) { | ||||
|                     $time = "0:".$time; | ||||
|                 } | ||||
|                 $program = new Programs(); | ||||
|                 $program->name = $match["content"]; | ||||
|                 $video_pivot = new ProgramVideos(); | ||||
|                 $video_pivot->video_bvid = $bvid; | ||||
|                 $video_pivot->start_part = $match["part"]; | ||||
|                 $video_pivot->start_time = $time; | ||||
|                 $video_pivot->stop_part = $match["part"]; | ||||
|                 $program->save(); | ||||
|                 $program->video_pivots()->save($video_pivot); | ||||
|             } | ||||
|         } | ||||
|         return redirect(route("program.construct.list")); | ||||
|     } | ||||
| 
 | ||||
|     public function edit(Request $request, Programs $program) { | ||||
|         return view("program.construct.create", [ | ||||
|             "program"=>$program | ||||
| @@ -24,6 +86,9 @@ class ProgramConstructController extends BaseController | ||||
|     } | ||||
| 
 | ||||
|     public function submit(Request $request, Programs $program) { | ||||
|         $request->validate([ | ||||
|             "name" => ["required"] | ||||
|         ]); | ||||
|         $updatePayload = $request->only(["name", "difficulty", "desc"]); | ||||
|         $program->status = $request->post("status", 0); | ||||
|         $program->update($updatePayload); | ||||
|   | ||||
| @@ -17,6 +17,44 @@ class ProgramVideoConstructController extends BaseController | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     public function add(Request $request) { | ||||
|         return view("program.construct.video.create", [ | ||||
|             "program_video" => new ProgramVideos() | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     public function create(Request $request, Programs $program) { | ||||
|         $request->validate([ | ||||
|             "start_part" => ["required", "int"], | ||||
|             "stop_part" => ["required", "int"], | ||||
|             "start_time" => ["required", "date_format:H:i:s"], | ||||
|             "stop_time" => ["required", "date_format:H:i:s"], | ||||
|             "created_at" => ["required", "date"], | ||||
|         ]); | ||||
|         $program_video = new ProgramVideos(); | ||||
|         $createPayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]); | ||||
|         $program_video->fill($createPayload); | ||||
|         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; | ||||
|         } | ||||
|         $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 | ||||
|         ])); | ||||
|     } | ||||
| 
 | ||||
|     public function edit(Request $request, ProgramVideos $program_video) { | ||||
|         return view("program.construct.video.create", [ | ||||
|             "program_video" => $program_video | ||||
| @@ -24,6 +62,13 @@ class ProgramVideoConstructController extends BaseController | ||||
|     } | ||||
| 
 | ||||
|     public function submit(Request $request, ProgramVideos $program_video) { | ||||
|         $request->validate([ | ||||
|             "start_part" => ["required", "int"], | ||||
|             "stop_part" => ["required", "int"], | ||||
|             "start_time" => ["required", "date_format:H:i:s"], | ||||
|             "stop_time" => ["required", "date_format:H:i:s"], | ||||
|             "created_at" => ["required", "date"], | ||||
|         ]); | ||||
|         $updatePayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]); | ||||
|         if ($request->hasFile("start_image")) { | ||||
|             $file = $request->file("start_image"); | ||||
|   | ||||
							
								
								
									
										18
									
								
								app/Http/Controllers/VideoQueryController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								app/Http/Controllers/VideoQueryController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Http\Controllers; | ||||
| 
 | ||||
| use App\Models\Videos; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Routing\Controller as BaseController; | ||||
| 
 | ||||
| class VideoQueryController extends BaseController | ||||
| { | ||||
|     public function info(Request $request, Videos $video) | ||||
|     { | ||||
|         return view("video.index", [ | ||||
|             "video" => $video, | ||||
|             "video_pivots" => $video->program_pivots | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user