Searching encrypted columns
Is it possible to search encrypted columns in filament tables? In my DB, i encrypted a users first_name, preferred_name and last_name, then have a full_name attribute. Here is the code I use to display the users name in the table, but search just doesn't work - I assume because search works on the DB, where the columns are encrypted:
1 Reply
Why It Doesn’t Work
Filament’s ->searchable() relies on SQL-level filtering, meaning the search query is executed on the database side. Since encrypted fields are stored as ciphertext, SQL cannot match or search them — the database doesn’t “know” what the decrypted values are. What You Can Do
You can’t directly search encrypted columns in SQL unless you:
Index unencrypted duplicates of the fields (not secure unless access-controlled carefully).
Use client-side or Laravel-level filtering after fetching and decrypting the records.
Possible Workaround (Laravel Collection Filtering):
If you can fetch all records first, then filter using Laravel (in memory), you can do
You’re right: it doesn’t work because SQL can’t search encrypted data.
Consider decrypting on the Laravel side and filtering in PHP, or rethink the encryption/search approach with security trade-offs in mind.