Conditions | 2 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function apply($query): Builder |
||
18 | { |
||
19 | $field_row = explode('.', $this->filter); |
||
20 | $field_row = end($field_row); |
||
21 | |||
22 | $conditions = str_replace('.'.$field_row, '', $this->filter); |
||
23 | |||
24 | $value = $this->values; |
||
25 | |||
26 | return $query->whereHas( |
||
27 | $conditions, |
||
28 | function ($q) use ($value, $field_row) { |
||
29 | $condition = 'where'; |
||
30 | if (is_array($value)) { |
||
31 | $condition = 'whereIn'; |
||
32 | } |
||
33 | $q->$condition($field_row, $value); |
||
34 | } |
||
38 |