1 | <?php |
||
2 | |||
3 | namespace IproSync\Models; |
||
4 | |||
5 | trait HasTraitsWithCasts |
||
6 | { |
||
7 | 3 | public function getCasts() |
|
8 | { |
||
9 | 3 | $class = static::class; |
|
10 | |||
11 | 3 | foreach (class_uses_recursive($class) as $trait) { |
|
12 | 3 | $method = 'get'.class_basename($trait).'CastsAttr'; |
|
13 | |||
14 | 3 | if (method_exists($class, $method)) { |
|
15 | 3 | $this->casts = array_merge($this->casts, $this->{$method}()); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
16 | } |
||
17 | } |
||
18 | |||
19 | 3 | return parent::getCasts(); |
|
20 | } |
||
21 | } |
||
22 |