mercredi 14 février 2018

Encrypt/Decrypt DB fields in laravel

I am encrypting/decrypting the DB field values in Laravel through accessors and mutators, which is working fine in normal eloquent transactions.

class Person extends Model
{
    use Notifiable;
    protected $table = 'person';

    public function getFirstNameAttribute($value)
    {
        return Crypt::decryptString($value);
    }
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = array();

    protected function user()
    {
        return $this->belongsTo('App\Models\User', 'useraccount_id', 'id');
    }
}

But the encryption and decryption not working under the following conditions

1) Eloquent relationships 2) DB raw queries

Kindly provide me a feasible solution for the same.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire