第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

無法返回“添加錯(cuò)誤的提示”

添加成功的例子過了,但是添加錯(cuò)誤的時(shí)候而比如不輸入年齡就直接會(huì)報(bào)錯(cuò),而不是返回頁面,

<!--?成功提示框?-->
@if(Session::has('success'))
<div?class="alert?alert-success?alert-dismissible">
????<button?type="buttn"?class="close"?data-dismiss="alert"?aria-label="Close"><span?aria-hidden="true">&times;</span>
????</button>
????<strong>成功!</strong>{{session::get('success')}}<!--?操作成功提示?-->??????</div>
@endif
<!--?失敗提示框?-->
@if(Session::has('error'))
<div?class="alert?alert-danger?alert-dismissible">
????<button?type="buttn"?class="close"?data-dismiss="alert"?aria-label="Close"><span?aria-hidden="true">&times;</span>
????</button>
????<strong>失??!</strong><!--?操作失敗提示?-->?{{session::get('error')}}?????</div>
@endif
public?function?save(Request?$request){
????$data=$request->input('student');
????$student=new?Studentm();
????$student->name=$data['name'];
????$student->age=$data['age'];
????$student->sex=$data['sex'];
????if(!$student->save()){
????????return?redirect('Student/index')->with('success','添加成功');
????}else{
????????redirect()->back();
????}
????return?view('student.create');
}


正在回答

1 回答

沒有添加驗(yàn)證 ?需要在添加之前加入驗(yàn)證?

$validator=\Validator::make($request->input(),[
????'student.name'=>'required|min:2|max:10',
????'student.age'=>'required|integer',
????'student.sex'=>'required|integer'
],[
????'required'=>":attribute不能為空",
????'integer'=>":attribute必須是整數(shù)",
????'min'=>':attribute最小不能少于2字符'
],[
????'student.name'=>'姓名',
????'student.age'=>'年齡',
????'student.sex'=>'性別'
]);
if($validator->fails()){
????return?redirect()->back()->withErrors($validator)->withInput();
}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

無法返回“添加錯(cuò)誤的提示”

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)