1 | <?php |
||||||
2 | |||||||
3 | namespace Sfneal\Tracking\Builders\Traits; |
||||||
4 | |||||||
5 | use Sfneal\Helpers\Strings\StringHelpers; |
||||||
6 | |||||||
7 | trait WhereModels |
||||||
8 | { |
||||||
9 | /** |
||||||
10 | * Scope query to activity on a specific trackable id. |
||||||
11 | * |
||||||
12 | * @param mixed $trackable_id |
||||||
13 | * @return $this |
||||||
14 | */ |
||||||
15 | public function whereTrackableId($trackable_id): self |
||||||
16 | { |
||||||
17 | $trackable_id = (array) $trackable_id; |
||||||
18 | $this->where(function (self $query) use ($trackable_id) { |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
19 | foreach ($trackable_id as $key) { |
||||||
20 | $query->orWhere('trackable_id', '=', $key); |
||||||
0 ignored issues
–
show
It seems like
orWhere() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
21 | } |
||||||
22 | }); |
||||||
23 | |||||||
24 | return $this; |
||||||
25 | } |
||||||
26 | |||||||
27 | /** |
||||||
28 | * Scope query to activity on a specific trackable type. |
||||||
29 | * |
||||||
30 | * @param mixed $trackable_type |
||||||
31 | * @return $this |
||||||
32 | */ |
||||||
33 | public function whereTrackableType($trackable_type): self |
||||||
34 | { |
||||||
35 | $trackable_type = (array) $trackable_type; |
||||||
36 | $this->where(function (self $query) use ($trackable_type) { |
||||||
37 | foreach ($trackable_type as $table) { |
||||||
38 | if ((new StringHelpers($table))->inString('_')) { |
||||||
39 | $query->orWhereLike('trackable_type', $table); |
||||||
0 ignored issues
–
show
It seems like
orWhereLike() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
40 | } else { |
||||||
41 | $query->orWhere('trackable_type', '=', $table); |
||||||
42 | } |
||||||
43 | } |
||||||
44 | }); |
||||||
45 | |||||||
46 | return $this; |
||||||
47 | } |
||||||
48 | } |
||||||
49 |