yabhq / laravel-scout-mysql-driver

Laravel Scout MySQL Driver
MIT License
522 stars 113 forks source link

Searching Model with Accessor #37

Closed poxin13 closed 7 years ago

poxin13 commented 7 years ago

I'm not sure if this would be more a Scout limitation or the driver here.

I have a model that contains a table for a phone number. Unfortunately I'm working with an existing database where they did not standardize these fields, as such phone numbers can contain dashes, spaces, parenthesis, etc.

So as a result I'm using a Accessor on this:

public function getPhoneAttribute($value)
    {
        return preg_replace("/[^A-Za-z0-9]/", "", $value);
    }

However, when utilizing search it seems to ignore this and still looks for the original value with dashes, etc.

poxin13 commented 7 years ago

I was not aware that Mutators do not affect any queries in Laravel. Closing this.