1 | <?php |
||
21 | trait GeneratesUuid |
||
22 | { |
||
23 | /** |
||
24 | * The UUID versions. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $uuidVersions = [ |
||
29 | 'uuid1', |
||
30 | 'uuid3', |
||
31 | 'uuid4', |
||
32 | 'uuid5', |
||
33 | 'ordered', |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * Determine whether an attribute should be cast to a native type. |
||
38 | * |
||
39 | * @param string $key |
||
40 | * @param array|string|null $types |
||
41 | * @return bool |
||
42 | */ |
||
43 | abstract public function hasCast($key, $types = null); |
||
44 | |||
45 | /** |
||
46 | * Boot the trait, adding a creating observer. |
||
47 | * |
||
48 | * When persisting a new model instance, we resolve the UUID field, then set |
||
49 | * a fresh UUID, taking into account if we need to cast to binary or not. |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public static function bootGeneratesUuid() |
||
67 | |||
68 | /** |
||
69 | * Resolve a UUID instance for the configured version. |
||
70 | * |
||
71 | * @return \Ramsey\Uuid\Uuid |
||
72 | */ |
||
73 | 7 | public function resolveUuid() |
|
81 | |||
82 | /** |
||
83 | * Resolve the UUID version to use when setting the UUID value. Default to uuid4. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 13 | public function resolveUuidVersion() |
|
95 | |||
96 | /** |
||
97 | * Scope queries to find by UUID. |
||
98 | * |
||
99 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
100 | * @param string $uuid |
||
101 | * |
||
102 | * @return \Illuminate\Database\Eloquent\Builder |
||
103 | */ |
||
104 | 2 | public function scopeWhereUuid($query, $uuid) |
|
112 | |||
113 | /** |
||
114 | * Cast an attribute to a native PHP type. |
||
115 | * |
||
116 | * @param string $key |
||
117 | * @param mixed $value |
||
118 | * @return mixed |
||
119 | */ |
||
120 | 3 | protected function castAttribute($key, $value) |
|
128 | } |
||
129 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: