错误提示及保留input

This commit is contained in:
Jerry Yan 2022-08-20 11:49:13 +08:00
parent c452e6a486
commit d897e9a33d
Signed by: q792602257
GPG Key ID: D070F653AF6C0004
3 changed files with 6 additions and 9 deletions

View File

@ -5,8 +5,10 @@ namespace App\Http\Controllers;
use App\Models\Programs; use App\Models\Programs;
use App\Models\ProgramVideos; use App\Models\ProgramVideos;
use App\Models\VideoComments; use App\Models\VideoComments;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\DB;
class ProgramConstructController extends BaseController class ProgramConstructController extends BaseController
{ {
@ -57,10 +59,8 @@ class ProgramConstructController extends BaseController
$content = $request->post("content"); $content = $request->post("content");
$count = ProgramVideos::query()->where("video_bvid", "=", $bvid)->count(); $count = ProgramVideos::query()->where("video_bvid", "=", $bvid)->count();
if ($count > 0) { if ($count > 0) {
return view("program.construct.batch_add", [ return back()->withInput()->withErrors([
"content" => $content, "bvid" => "该BVID下已有{$count}个节目关联,请手动添加"
"bvid" => $bvid,
"message" => "该BVID下已有{$count}个节目关联,请手动添加",
]); ]);
} }
$regex = "/^p(?P<part>\d{1,2})[-# _:,)]+(?P<time>(0?1[:])?\d{1,3}[:]\d{1,2}) ?(?P<content>.+)$/ui"; $regex = "/^p(?P<part>\d{1,2})[-# _:,)]+(?P<time>(0?1[:])?\d{1,3}[:]\d{1,2}) ?(?P<content>.+)$/ui";

View File

@ -103,7 +103,7 @@ class ProgramVideoConstructController extends BaseController
public function to_fix_created_at(Request $request, ProgramVideos $program_video) { public function to_fix_created_at(Request $request, ProgramVideos $program_video) {
if ($program_video->created_at === null) { if ($program_video->created_at === null) {
return back()->withErrors([ return back()->withInput()->withErrors([
"id" => "没有开始时间,请先保存对应时间" "id" => "没有开始时间,请先保存对应时间"
]); ]);
} }
@ -118,7 +118,7 @@ class ProgramVideoConstructController extends BaseController
"each_time" => ["required", "date_format:H:i:s"] "each_time" => ["required", "date_format:H:i:s"]
]); ]);
if ($program_video->created_at === null) { if ($program_video->created_at === null) {
return back()->withErrors([ return back()->withInput()->withErrors([
"id" => "没有开始时间,请先保存对应时间" "id" => "没有开始时间,请先保存对应时间"
]); ]);
} }

View File

@ -18,9 +18,6 @@
<input class="form-input border-0 border-b-2 w-full" type="text" name="bvid" required value="{{ old('bvid') }}"> <input class="form-input border-0 border-b-2 w-full" type="text" name="bvid" required value="{{ old('bvid') }}">
</label> </label>
@include("common.form_error") @include("common.form_error")
@isset($message)
<div class="bg-red-600 text-white">提示:{{ $message }}</div>
@endisset
<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>