I'm working on this model with name field encrypted using Crypt class, i can display data into decrypted in view. but when searching for the value in the model that is encrypted. my controller returns null.
//heres my code: validator model. //validator->validate($code)
return $this->validator
->where('name', '=', $code)
->where('date_end', '>=', $dateToday)
->where('availability', '=' ,0)
->first();
//and note, im using traits for auto encryption and decryption for my model
trait Encryptable {
public function getAttribute($key){
$value = parent::getAttribute($key);
if(in_array($key, $this->encryptable)){
$value = Crypt::decrypt($value);
}
return $value;
}
public function setAttribute($key, $value)
{
if(in_array($key, $this->encryptable)){
$value = Crypt::encrypt($value);
}
return parent::setAttribute($key, $value);
}
}
please help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire