mercredi 29 juin 2016

illegal string offset 'name' when working with password fields laravel 4.2

hi i have this custom validation i declared in my start->global.php what it does is compare the password inside the database and the entered 'current password' here is the code

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;
 }

});

in my controller im calling it like this

$uid = Session::get('sid');
    $rules = array(
        'ecp'   => 'required|min:8|max:255|chkcpass:'.$uid,
        'np'    => 'required',
        'rnp'   => 'required',
    );

and in my view here is the form

{{ 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() }}

but im getting an error saying i have an error in my view blade about

Illegal string offset 'name' 

any ideas what i am doing wrong? thanks so much in advance!

Aucun commentaire:

Enregistrer un commentaire