Conditions | 4 |
Paths | 3 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
9 | public function __invoke(Builder $query, $value, string $property, ?string $modifier = null): Builder |
||
10 | { |
||
11 | if ($this->isRelationProperty($query, $property)) { |
||
12 | return $this->withRelationConstraint($query, $value, $property); |
||
13 | } |
||
14 | |||
15 | $wrappedProperty = $query->getQuery()->getGrammar()->wrap($property); |
||
16 | |||
17 | $sql = "LOWER({$wrappedProperty}) LIKE ?"; |
||
18 | |||
19 | if (is_array($value)) { |
||
20 | return $query->orWhere(function (Builder $query) use ($value, $sql) { |
||
21 | foreach ($value as $partialValue) { |
||
22 | $partialValue = mb_strtolower($partialValue, 'UTF8'); |
||
23 | |||
24 | $query->orWhereRaw($sql, [$this->encloseValue($partialValue)]); |
||
25 | } |
||
26 | }); |
||
27 | } |
||
28 | |||
29 | $value = mb_strtolower($value, 'UTF8'); |
||
30 | |||
31 | return $query->orWhereRaw($sql, [$this->encloseValue($value)]); |
||
32 | } |
||
33 | |||
39 |