Just some tlc
This commit is contained in:
@ -27,9 +27,8 @@ abstract class BaseMatcher implements MatcherInterface
|
|||||||
*/
|
*/
|
||||||
public function buildQueryString($column, $searchString)
|
public function buildQueryString($column, $searchString)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'formatSearchString')) {
|
if (method_exists($this, 'formatSearchString'))
|
||||||
$searchString = $this->formatSearchString($searchString);
|
$searchString = $this->formatSearchString($searchString);
|
||||||
}
|
|
||||||
|
|
||||||
return "IF($column {$this->operator} '$searchString', {$this->multiplier}, 0)";
|
return "IF($column {$this->operator} '$searchString', {$this->multiplier}, 0)";
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,10 @@ class SearchBuilder
|
|||||||
*/
|
*/
|
||||||
public function search($searchable)
|
public function search($searchable)
|
||||||
{
|
{
|
||||||
if (is_object($searchable) && method_exists($searchable, 'getTable')) {
|
// Check if table name or Eloquent
|
||||||
$this->table = $searchable->getTable();
|
$isEloquent = is_object($searchable) && method_exists($searchable, 'getTable');
|
||||||
} else {
|
|
||||||
$this->table = $searchable;
|
$this->table = $isEloquent ? $searchable->getTable() : $searchable;
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -95,18 +94,17 @@ class SearchBuilder
|
|||||||
|
|
||||||
// Check if default driver is being overridden, otherwise
|
// Check if default driver is being overridden, otherwise
|
||||||
// load the default
|
// load the default
|
||||||
if ($this->driverName) {
|
$driverName = $this->driverName ? $this->driverName : $this->config->get('searchy.default');
|
||||||
$driverName = $this->driverName;
|
|
||||||
} else {
|
|
||||||
$driverName = $this->config->get('searchy.default');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets the details for the selected driver from the configuration file
|
// Gets the details for the selected driver from the configuration file
|
||||||
$driver = $this->config->get("searchy.drivers.$driverName")['class'];
|
$driver = $this->config->get("searchy.drivers.$driverName")['class'];
|
||||||
|
|
||||||
// Create a new instance of the selected drivers 'class' and pass
|
// Create a new instance of the selected drivers 'class' and pass
|
||||||
// through table and fields to search
|
// through table and fields to search
|
||||||
$driverInstance = new $driver($this->table, $this->searchFields, $relevanceFieldName, ['*']);
|
$driverInstance = new $driver( $this->table,
|
||||||
|
$this->searchFields,
|
||||||
|
$relevanceFieldName,
|
||||||
|
['*']);
|
||||||
|
|
||||||
return $driverInstance;
|
return $driverInstance;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user