You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Besides the where clauses, and orderBy would also be useful. In order to be able to sort the data by encrypted fields, I extended the EloquentBuilder class and added the following code:
class CustomEloquentBuilder extends EncryptionEloquentBuilder
{
public function orderByEncrypted($column, $direction = 'asc') {
$salt = substr(hash('sha256', env('APP_KEY')), 0, 16);
return self::orderByRaw("CONVERT(AES_DECRYPT(FROM_bASE64(`{$column}`), '{$salt}') USING utf8mb4) {$direction}");
}
}
trait CustomEncryptedAttribute
{
use EncryptedAttribute;
public function newEloquentBuilder($query)
{
return new CustomEloquentBuilder($query);
}
}
It would be great to have it as a built-it function in the package.
The text was updated successfully, but these errors were encountered:
Besides the where clauses, and orderBy would also be useful. In order to be able to sort the data by encrypted fields, I extended the EloquentBuilder class and added the following code:
It would be great to have it as a built-it function in the package.
The text was updated successfully, but these errors were encountered: