3 days ago

Crypt in Eloquent Query

Posted 3 days ago by myselfaaryan

Hello, so I am defining a relationship with a user and the core database where all entries are encrypted. For this I have assigned an encrypted key to each user so that using the eloquent query I can find out which row belongs to which user.

$get = Model::firstWhere('key', Crypt::decrypt(Auth::user()->key));

The 'key' is also encrypted in the core db.

I am using the encryptable trait which automatically decrypts the key on call. But however for some reason it is not decrypting it in the eloquent query. Obviously, now there's something wrong with my code here. Is there a way out of this or any alternative?

Please sign in or create an account to participate in this conversation.