mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Fixes the generation of where conditions (#5902)
This commit is contained in:
parent
b6e3715cd8
commit
45a2932f4b
|
@ -68,6 +68,8 @@ trait Searchable {
|
|||
|
||||
$table = $this->getTable();
|
||||
|
||||
$firstConditionAdded = false;
|
||||
|
||||
foreach($this->getSearchableAttributes() as $column) {
|
||||
|
||||
foreach($terms as $term) {
|
||||
|
@ -80,6 +82,19 @@ trait Searchable {
|
|||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to form the query properly, starting with a "where",
|
||||
* otherwise the generated select is wrong.
|
||||
*
|
||||
* @todo This does the job, but is inelegant and fragile
|
||||
*/
|
||||
if (!$firstConditionAdded) {
|
||||
$query = $query->where($table . '.' . $column, 'LIKE', '%'.$term.'%');
|
||||
|
||||
$firstConditionAdded = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$query = $query->orWhere($table . '.' . $column, 'LIKE', '%'.$term.'%');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue