| @@ 65-77 (lines=13) @@ | ||
| 62 | */ |
|
| 63 | $model->where(function ($q) use ($query, $conditionColumns, $relations) { |
|
| 64 | ||
| 65 | if (count($conditionColumns)) { |
|
| 66 | $column = 'LOWER('.array_shift($conditionColumns).')'; |
|
| 67 | if (Str::contains($column, '->')) { |
|
| 68 | $column = $this->wrapJsonSelector($column); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Use the first element in the model columns to construct the first condition. |
|
| 73 | */ |
|
| 74 | $q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%'); |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * Loop through the rest of the columns to construct or where conditions. |
|
| 79 | */ |
|
| 80 | foreach ($conditionColumns as $column) { |
|
| @@ 114-127 (lines=14) @@ | ||
| 111 | */ |
|
| 112 | $subConditionColumns = \Core::$relation()->model->searchable; |
|
| 113 | ||
| 114 | if (count($subConditionColumns)) { |
|
| 115 | $column = 'LOWER('.array_shift($subConditionColumns).')'; |
|
| 116 | if (Str::contains($column, '->')) { |
|
| 117 | $column = $this->wrapJsonSelector($column); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * Use the first element in the relation model columns to construct the first condition. |
|
| 122 | */ |
|
| 123 | $q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%'); |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * Loop through the rest of the columns to construct or where conditions. |
|
| 128 | */ |
|
| 129 | foreach ($subConditionColumns as $subConditionColumn) { |
|
| 130 | $column = 'LOWER('.$subConditionColumn.')'; |
|