嗨我有这个自定义验证我在我的开始 - > global.php中声明它做的是比较数据库内的密码和输入的'当前密码'这里是代码
Validator::extend('chkcpass', function($attribute, $value, $parameters){
$getAcc = DB::table('nsa_systemusers')
->where('sid' , '=' , $parameters)
->get();
foreach ($getAcc as $key => $gcp){
$ucp = $gcp->password;
}
$sptkey = md5('3982f3a0c86f272633fc7105040a83c8');
$decPass = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sptkey, base64_decode($ucp), MCRYPT_MODE_ECB));
if($value != $decPass){
return false;
}else{
return true;
}
});
在我的控制器中我称之为
$uid = Session::get('sid');
$rules = array(
'ecp' => 'required|min:8|max:255|chkcpass:'.$uid,
'np' => 'required',
'rnp' => 'required',
);
在我看来这是表格
{{ Form::open(array('url' => 'usrchangepassword')) }}
<div class="row">
<div class="input-field col s10">
{{ Form::label('pass', 'Enter Current Password') }}
{{ Form::password('ecp' , array('class' => 'form-control')) }}
</div>
</div>
<div class="row">
<div class="input-field col s10">
{{ Form::label('pass', 'Enter New Password') }}
{{ Form::password('np' , array('class' => 'form-control ')) }}
</div>
</div>
<div class="row">
<div class="input-field col s10">
{{ Form::label('pass', 'Re-type New Password') }}
{{ Form::password('rnp' , array('class' => 'form-control ')) }}
</div>
</div>
@if ($errors->any())
<div class='err'>
<ul>
{{ implode('', $errors->all('<strong><li class="ermsg">:message</li></strong>')) }}
</ul>
</div>
@endif
<br>
{{ Form::submit('save', array('class' => 'btn btn-primary savebtn')) }}
{{ Form::close() }}
但我收到错误,说我的视图刀片中有错误
Illegal string offset 'name'
任何想法我做错了什么?非常感谢!
答案 0 :(得分:0)
$getAcc = DB::table('nsa_systemusers')
->where('sid' , '=' , $parameters)
->get();
失败,因为$parameters
是一个数组。
如果要使用该数组,请使用以下方法:
->whereIn('sid', $parameters);