Skip to content

Conversation

@ginkelsoft-development
Copy link
Owner

No description provided.

Features:
- RebuildIndex command now checks and encrypts unencrypted fields during rebuild
- Detects non-encrypted data by checking for Laravel's encryption format prefix
- Automatically re-encrypts plaintext data in encrypted cast fields
- Reports number of fields encrypted during rebuild process

- Add encryptedSearchAny() scope for OR logic across multiple fields
- Add encryptedSearchAll() scope for AND logic with multiple field-term pairs
- Both methods support exact and prefix search types
- Compatible with database and Elasticsearch backends

Tests:
- All 106 tests passing
- BatchQueryTest now fully operational with new scope methods
- Rebuild command tested with encryption validation

Technical details:
- Uses getAttributes() to access raw database values
- Detects encrypted format by checking for 'eyJpdiI' prefix (base64 of '{"iv"')
- encryptedSearchAny() delegates to existing encryptedExactMulti/encryptedPrefixMulti
- encryptedSearchAll() builds chained whereIn conditions for AND logic
Improvements:
- Single-field prefix searches now sort by field length (shorter = more relevant)
- Exact matches like "Wilma" will appear before longer matches like "Wilmaaaa"
- Uses LENGTH() function which is compatible across MySQL, PostgreSQL, and SQLite

Technical details:
- Added orderByRaw("LENGTH({$field}) ASC") to scopeEncryptedPrefix
- Multi-field searches remain unsorted due to database function compatibility
- For best results with sorted relevance, use single-field prefix searches

Example:
Client::encryptedPrefix('first_names', 'Wilma')->get()
// Returns: Wilma, Wilmar, Wilmaaaa (sorted by length)
@ginkelsoft-development ginkelsoft-development merged commit ad54caa into develop Oct 14, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants