1 | <?php |
||||
2 | |||||
3 | namespace PrismX\Schemaless\Traits; |
||||
4 | |||||
5 | use PrismX\Schemaless\Document; |
||||
6 | |||||
7 | trait HasSchemalessRelationships |
||||
8 | { |
||||
9 | public function itemable(string $class = Document::class) |
||||
10 | { |
||||
11 | return $this->morphTo($this->getItemMorphColumnName()) |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
12 | ->where($this->getItemMorphColumnName().'_type', $class); |
||||
13 | } |
||||
14 | |||||
15 | /** |
||||
16 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||||
17 | */ |
||||
18 | public function item(string $class = Document::class) |
||||
0 ignored issues
–
show
The parameter
$class is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
19 | { |
||||
20 | return $this->morphOne(Document::class, $this->getItemMorphColumnName()); |
||||
0 ignored issues
–
show
It seems like
morphOne() 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 \Illuminate\Database\Eloquent\Relations\MorphMany |
||||
25 | */ |
||||
26 | public function items(string $class = Document::class) |
||||
0 ignored issues
–
show
The parameter
$class is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
27 | { |
||||
28 | return $this->morphMany(Document::class, $this->getItemMorphColumnName()); |
||||
0 ignored issues
–
show
It seems like
morphMany() 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
![]() |
|||||
29 | } |
||||
30 | |||||
31 | /** |
||||
32 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||||
33 | */ |
||||
34 | public function manyItems(string $class = Document::class) |
||||
35 | { |
||||
36 | return $this->morphToMany( |
||||
0 ignored issues
–
show
It seems like
morphToMany() 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
![]() |
|||||
37 | $class, |
||||
38 | 'child', |
||||
39 | 'item_items', |
||||
40 | 'child_id', |
||||
41 | 'parent_id' |
||||
42 | ) |
||||
43 | ->withPivot('parent_type', 'parent_id', 'child_type', 'child_id') |
||||
44 | ->wherePivot('parent_type', get_class($this)) |
||||
45 | ->withPivotValue('parent_type', get_class($this)); |
||||
46 | } |
||||
47 | |||||
48 | /** |
||||
49 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||||
50 | */ |
||||
51 | public function byManyItems(string $class = Document::class) |
||||
52 | { |
||||
53 | return $this->morphedByMany( |
||||
0 ignored issues
–
show
It seems like
morphedByMany() 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
![]() |
|||||
54 | $class, |
||||
55 | 'parent', |
||||
56 | 'item_items', |
||||
57 | 'parent_id', |
||||
58 | 'child_id' |
||||
59 | ) |
||||
60 | ->withPivot('parent_type', 'parent_id', 'child_type', 'child_id') |
||||
61 | ->wherePivot('child_type', get_class($this)) |
||||
62 | ->withPivotValue('child_type', get_class($this)); |
||||
63 | } |
||||
64 | |||||
65 | /** |
||||
66 | * @override |
||||
67 | * |
||||
68 | * @return string |
||||
69 | */ |
||||
70 | public function getItemMorphColumnName() |
||||
71 | { |
||||
72 | return 'itemable'; |
||||
73 | } |
||||
74 | } |
||||
75 |