1 | <?php |
||
9 | trait ModelConfiguration |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @return array |
||
14 | */ |
||
15 | public function getFillable() |
||
19 | |||
20 | /** |
||
21 | * @return mixed |
||
22 | */ |
||
23 | public function getHidden() |
||
27 | |||
28 | public function scopeSelectedUnits($query, $units) |
||
34 | |||
35 | /** |
||
36 | * Create a new instance of the given model. |
||
37 | * |
||
38 | * @param array $attributes |
||
39 | * @param bool $exists |
||
40 | * @return static |
||
41 | * @throws NotSupportedMultiUnitField |
||
42 | */ |
||
43 | public function newInstance($attributes = [], $exists = false) |
||
51 | |||
52 | /** |
||
53 | * Determine if a set mutator exists for an attribute. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function hasSetMutator($key) |
||
67 | |||
68 | /** |
||
69 | * Determine if a get mutator exists for an attribute. |
||
70 | *coo. |
||
71 | * |
||
72 | * @param string $key |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function hasGetMutator($key) |
||
84 | |||
85 | /** |
||
86 | * Get the value of an attribute using its mutator. |
||
87 | * |
||
88 | * @param string $key |
||
89 | * @param mixed $value |
||
90 | * |
||
91 | * @throws NotSupportedMultiUnitField |
||
92 | * |
||
93 | * @return mixed |
||
94 | */ |
||
95 | public function mutateAttribute($key, $value) |
||
110 | |||
111 | /** |
||
112 | * Allows to set input units and process them before multi-unit field. |
||
113 | * |
||
114 | * @param array $attributes |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | protected function fillableFromArray(array $attributes) |
||
122 | |||
123 | /** |
||
124 | * Set the value of an attribute using its mutator. |
||
125 | * |
||
126 | * @param string $key |
||
127 | * @param mixed $value |
||
128 | * |
||
129 | * @throws NotSupportedMultiUnitField |
||
130 | * |
||
131 | * @return mixed |
||
132 | */ |
||
133 | protected function setMutatedAttributeValue($key, $value) |
||
147 | |||
148 | /** |
||
149 | * Detect changes and set proper database value |
||
150 | * |
||
151 | * @param $field |
||
152 | * @param $value |
||
153 | * |
||
154 | * @throws NotSupportedMultiUnitField |
||
155 | * |
||
156 | * @return mixed |
||
157 | */ |
||
158 | private function processMultiUnitFieldChanges($field, $value) |
||
185 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.