| Conditions | 6 |
| Paths | 7 |
| Total Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | public function __invoke(Builder $query, $value, string $property) |
||
| 10 | { |
||
| 11 | if ($this->addRelationConstraint) { |
||
| 12 | if ($this->isRelationProperty($query, $property)) { |
||
| 13 | $this->withRelationConstraint($query, $value, $property); |
||
| 14 | |||
| 15 | return; |
||
| 16 | } |
||
| 17 | } |
||
| 18 | |||
| 19 | $wrappedProperty = $query->getQuery()->getGrammar()->wrap($property); |
||
| 20 | |||
| 21 | $sql = "LOWER({$wrappedProperty}) LIKE ?"; |
||
| 22 | |||
| 23 | if (is_array($value)) { |
||
| 24 | if (count(array_filter($value)) === 0) { |
||
| 25 | return $query; |
||
| 26 | } |
||
| 27 | |||
| 28 | $query->where(function (Builder $query) use ($value, $sql) { |
||
| 29 | foreach (array_filter($value) as $partialValue) { |
||
| 30 | $partialValue = mb_strtolower($partialValue, 'UTF8'); |
||
| 31 | |||
| 32 | $query->orWhereRaw($sql, ["%{$partialValue}%"]); |
||
| 33 | } |
||
| 34 | }); |
||
| 35 | |||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | $value = mb_strtolower($value, 'UTF8'); |
||
| 40 | |||
| 41 | $query->whereRaw($sql, ["%{$value}%"]); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |