Conditions | 4 |
Paths | 3 |
Total Lines | 28 |
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 | collect(explode(' ', mb_strtolower($partialValue, 'UTF8'))) |
||
23 | ->each(function($partialValue) use ($query, $sql) { |
||
24 | $query->orWhereRaw($sql, [$this->encloseValue($partialValue)]); |
||
25 | }); |
||
26 | } |
||
27 | }); |
||
28 | } |
||
29 | |||
30 | collect(explode(' ', mb_strtolower($value, 'UTF8'))) |
||
31 | ->each(function($value) use ($query, $sql) { |
||
32 | $query->orWhereRaw($sql, [$this->encloseValue($value)]); |
||
33 | }); |
||
34 | |||
35 | return $query; |
||
36 | } |
||
37 | |||
43 |