我有laravel更改密码,包含字段:oldpassword,newpasword,confirmedpassword 现在要验证表单,newpasword必须与confirmpassword相同,并且数据库中的此用户必须存在旧的
这是我的观看代码:
<div class="form-group">
<label for="oldpsw">your current password</label>
<input type="password" class="form-control" id="oldpsw"
placeholder="your current password" name="oldpsw">
@if ($errors->has('oldpsw'))
<span class="help-block">
<strong>{{ $errors->first('oldpsw') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password">new password</label>
<input type="password" class="form-control" id="password" placeholder="new
password" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
<div class="form-group">
<label for="password_confirmation">Password Confirmation</label>
<input type="password" class="form-control" id="password_confirmation"
placeholder="Password Confirmation" name="password_confirmation" required>
</div>
我的控制员:
return Validator::make($data, ['oldpsw' => 'required|string','password' => 'required|string|confirmed','password_confirmation' => 'required|string', 'password' =>Rule::exists('accounts')->where(function ($query) { $query->where('student_no', Auth::user()->student_no);}), ]);
如果我想使用|确认我的字段必须是模型可填写字段的名称,但是如果我想检查数据库是否存在它需要该字段也作为db中的同一列。 我的Db专栏是:密码,我该怎么做才能解决这个问题
编辑:我的意思是两个案例都必须命名两个字段:密码!