8 months ago

Using gregoryduckworth/Encryptable with spatie/laravel-searchable

Posted 8 months ago by nickdavies07

I'm using the package gregoryduckworth/Encryptable gregoryduckworth/encryptable to encrypt data as it enters the database and I'd also like to set up the spatie/laravel-searchable spatie/laravel-searchable package to search models.

Unfortunately, I'm running into an issue with the data not decrypting when searching. If I search the actual encrypted data i.e. eyJpdiI6Im1sK1dQXC9STlVTMHlvUDVoRFlnaERRPT0iLCJ2YWx1ZSI6ImcwRFFzK0h6Z2NMRGhCc01tVm15aGc9PSIs the result is returned.

Is there any way around this at all?


// Encrypted attributes
    protected $encryptable = [


// Encrypted attributes
    protected $encryptable = [
        'title', 'body'


    public function search(Request $request)
        $searchResults = (new Search())
            ->registerModel(Student::class, 'forename')
            ->registerModel(Concern::class, 'title')
        return view('search', compact('searchResults'));

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