@ -57,6 +57,11 @@ For example, if you want to search the name, email address and username of a use
$users = Searchy::users('name', 'email', 'username')->query('John Smith');
```
#### Searching Joined/Concatenated Columns
Sometimes you may want to leverage searches on concatenated column. For example, on a `first_name` and `last_name` field but you only want to run the one query. To do this can separate columns with a double colon:
```php
$users = Searchy::users('first_name::last_name')->query('John Smith');
Configuration
----------------------------------------
@ -34,6 +34,6 @@ class ConsecutiveCharactersMatcher extends BaseMatcher
{
$searchString = $this->formatSearchString( $rawString );
return "IF($column {$this->operator} '$searchString', ROUND({$this->multiplier} * (CHAR_LENGTH( '$rawString' ) / CHAR_LENGTH( REPLACE($column, ' ', '') ))), 0)";
return "IF(REPLACE($column, '\.', '') {$this->operator} '$searchString', ROUND({$this->multiplier} * (CHAR_LENGTH( '$rawString' ) / CHAR_LENGTH( REPLACE($column, ' ', '') ))), 0)";
}
@ -63,7 +63,12 @@ abstract class BaseSearchDriver implements SearchDriverInterface {
$query = [];
foreach ($searchFields as $searchField) {
$query[] = $this->buildSelectCriteria( $searchField );
if (strpos($searchField, '::')){
$concatString = explode('::', $searchField);
$query[] = $this->buildSelectCriteria( "CONCAT({$concatString[0]}, ' ', {$concatString[1]})");
} else {
return \DB::raw(implode(' + ', $query) . ' AS ' . \Config::get('searchy::fieldName'));