| @@ 68-80 (lines=13) @@ | ||
| 65 | */ |
|
| 66 | $model->where(function ($q) use ($query, $conditionColumns, $relations){ |
|
| 67 | ||
| 68 | if (count($conditionColumns)) |
|
| 69 | { |
|
| 70 | $column = 'LOWER(' . array_shift($conditionColumns) . ')'; |
|
| 71 | if (str_contains($column, '->')) |
|
| 72 | { |
|
| 73 | $column = $this->wrapJsonSelector($column); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Use the first element in the model columns to construct the first condition. |
|
| 78 | */ |
|
| 79 | $q->where(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%'); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Loop through the rest of the columns to construct or where conditions. |
|
| @@ 123-136 (lines=14) @@ | ||
| 120 | */ |
|
| 121 | $subConditionColumns = \Core::$relation()->model->searchable; |
|
| 122 | ||
| 123 | if (count($subConditionColumns)) |
|
| 124 | { |
|
| 125 | ||
| 126 | $column = 'LOWER(' . array_shift($subConditionColumns) . ')'; |
|
| 127 | if (str_contains($column, '->')) |
|
| 128 | { |
|
| 129 | $column = $this->wrapJsonSelector($column); |
|
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * Use the first element in the relation model columns to construct the first condition. |
|
| 134 | */ |
|
| 135 | $q->where(\DB::raw($column), 'LIKE', '%' . strtolower($query) . '%'); |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * Loop through the rest of the columns to construct or where conditions. |
|