1 | <?php |
||
15 | trait HasEnums |
||
16 | { |
||
17 | 64 | public function setAttribute($key, $value) |
|
23 | |||
24 | 28 | public function getAttribute($key) |
|
32 | |||
33 | /** |
||
34 | * @param Builder $builder |
||
35 | * @param string $key |
||
36 | * @param int|string|Enumerable|int[]|string[]|Enumerable[] $enumerables |
||
37 | * |
||
38 | * @see Builder::whereIn() |
||
39 | */ |
||
40 | 24 | public function scopeWhereEnum( |
|
52 | |||
53 | /** |
||
54 | * @param Builder $builder |
||
55 | * @param string $key |
||
56 | * @param int|string|Enumerable|int[]|string[]|Enumerable[] $enumerables |
||
57 | * |
||
58 | * @see Builder::orWhereIn() |
||
59 | */ |
||
60 | public function scopeOrWhereEnum( |
||
72 | |||
73 | /** |
||
74 | * @param Builder $builder |
||
75 | * @param string $key |
||
76 | * @param int|string|Enumerable|int[]|string[]|Enumerable[] $enumerables |
||
77 | * |
||
78 | * @see Builder::whereNotIn() |
||
79 | */ |
||
80 | 12 | public function scopeWhereNotEnum( |
|
92 | |||
93 | /** |
||
94 | * @param Builder $builder |
||
95 | * @param string $key |
||
96 | * @param int|string|Enumerable|int[]|string[]|Enumerable[] $enumerables |
||
97 | * |
||
98 | * @see Builder::orWhereNotIn() |
||
99 | */ |
||
100 | public function scopeOrWhereNotEnum( |
||
112 | |||
113 | /** |
||
114 | * @param string $key |
||
115 | * @param int|string|Enumerable $value |
||
116 | * |
||
117 | * @return $this |
||
118 | */ |
||
119 | 64 | protected function setEnumAttribute(string $key, $value) |
|
135 | |||
136 | /** |
||
137 | * @param string $key |
||
138 | * @param Enumerable $enum |
||
139 | * |
||
140 | * @return int|string |
||
141 | */ |
||
142 | 56 | protected function getStoredValue(string $key, Enumerable $enum) |
|
148 | |||
149 | /** |
||
150 | * @param string $key |
||
151 | * @param int|string $value |
||
152 | * @return Enumerable |
||
153 | */ |
||
154 | 56 | protected function getEnumAttribute(string $key, $value): Enumerable |
|
158 | |||
159 | 72 | protected function isEnumAttribute(string $key): bool |
|
163 | |||
164 | 64 | protected function getEnumClass(string $key): string |
|
176 | |||
177 | /** |
||
178 | * @param string $class |
||
179 | * @param int|string $value |
||
180 | * |
||
181 | * @return Enumerable |
||
182 | */ |
||
183 | 56 | protected function asEnum(string $class, $value): Enumerable |
|
194 | |||
195 | /** |
||
196 | * @param Builder $builder |
||
197 | * @param string $method |
||
198 | * @param string $key |
||
199 | * @param int|string|Enumerable|int[]|string[]|Enumerable[] $enumerables |
||
200 | */ |
||
201 | 36 | protected function buildEnumScope( |
|
220 | } |
||
221 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: