1 | <?php |
||
15 | abstract class Field |
||
16 | { |
||
17 | use FieldHasUiModifiers; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | const TYPE = 'type'; |
||
23 | |||
24 | /** |
||
25 | * @var bool |
||
26 | */ |
||
27 | const MULTIPART = false; |
||
28 | |||
29 | /** |
||
30 | * @var CrudFields |
||
31 | */ |
||
32 | protected $fields; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $identifier; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $rules; |
||
43 | |||
44 | /** |
||
45 | * Field constructor. |
||
46 | * |
||
47 | * @param string $identifier |
||
48 | * @param array|string $rules |
||
49 | */ |
||
50 | public function __construct($identifier, $rules = null) |
||
59 | |||
60 | /** |
||
61 | * Constructs staticly. |
||
62 | * |
||
63 | * @param string $idenfitier |
||
64 | * @param null|string|array $rules |
||
65 | * @return static |
||
66 | */ |
||
67 | public static function handle($idenfitier, $rules = null) |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Add validation rules to the field. |
||
75 | * |
||
76 | * @param string|array $rules |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function withRules($rules) |
||
105 | |||
106 | /** |
||
107 | * Add a validation rule. |
||
108 | * |
||
109 | * @param string $rule |
||
110 | * @return self |
||
111 | */ |
||
112 | public function addRule($rule) |
||
118 | |||
119 | /** |
||
120 | * @param CrudFields $fields |
||
121 | * @return self |
||
122 | */ |
||
123 | public function setFields(CrudFields $fields) |
||
129 | |||
130 | /** |
||
131 | * @param void |
||
132 | * @return CrudFields |
||
133 | */ |
||
134 | public function getFields() |
||
138 | |||
139 | /** |
||
140 | * Get the field identifier. |
||
141 | * |
||
142 | * @param void |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getIdentifier() |
||
149 | |||
150 | /** |
||
151 | * Render the field form. |
||
152 | * |
||
153 | * @param void |
||
154 | * @return string |
||
155 | */ |
||
156 | public function form() |
||
160 | |||
161 | /** |
||
162 | * Get the form view. |
||
163 | * |
||
164 | * @param void |
||
165 | * @return View |
||
166 | */ |
||
167 | protected function getForm() |
||
171 | |||
172 | /** |
||
173 | * Get the field view name. |
||
174 | * |
||
175 | * @param void |
||
176 | * @return string |
||
177 | */ |
||
178 | abstract public function getViewName(); |
||
179 | |||
180 | /** |
||
181 | * Returns additionnal variables to the views. |
||
182 | * |
||
183 | * @param void |
||
184 | * @return array |
||
185 | */ |
||
186 | protected function getViewVariables() |
||
190 | |||
191 | /** |
||
192 | * Returns all base variables for the view. |
||
193 | * |
||
194 | * @param void |
||
195 | * @return array |
||
196 | */ |
||
197 | protected function getViewBaseVariables() |
||
215 | |||
216 | /** |
||
217 | * Checks if the field has an error. |
||
218 | * |
||
219 | * @param void |
||
220 | * @return bool |
||
221 | */ |
||
222 | public function hasError() |
||
226 | |||
227 | /** |
||
228 | * Returns the error. |
||
229 | * |
||
230 | * @param void |
||
231 | * @return null|string |
||
232 | */ |
||
233 | public function getError() |
||
242 | |||
243 | /** |
||
244 | * Checks if the field has a previous value. |
||
245 | * |
||
246 | * @param void |
||
247 | * @return bool |
||
248 | */ |
||
249 | public function hasOld() |
||
253 | |||
254 | /** |
||
255 | * Returns the old value. |
||
256 | * |
||
257 | * @param void |
||
258 | * @return string|null |
||
259 | */ |
||
260 | public function getOld() |
||
269 | |||
270 | /** |
||
271 | * Get the field value. |
||
272 | * |
||
273 | * @param void |
||
274 | * @return mixed |
||
275 | */ |
||
276 | public function getValue() |
||
285 | |||
286 | /** |
||
287 | * Get the value to be displayed on a table. |
||
288 | * |
||
289 | * @param void |
||
290 | * @return mixed |
||
291 | */ |
||
292 | public function getTableValue() |
||
296 | |||
297 | /** |
||
298 | * Set a new value to the model. |
||
299 | * |
||
300 | * @param mixed $value |
||
301 | * @return self |
||
302 | */ |
||
303 | public function newValue($value) |
||
312 | |||
313 | /** |
||
314 | * @param void |
||
315 | * @return string |
||
316 | */ |
||
317 | public function getRules() |
||
321 | |||
322 | /** |
||
323 | * @param Validator $validator |
||
324 | * @return Validator |
||
325 | */ |
||
326 | public function beforeValidation(Validator $validator) |
||
330 | |||
331 | /** |
||
332 | * @param void |
||
333 | * @return self |
||
334 | */ |
||
335 | public function beforeSave() |
||
339 | } |
||
340 |
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: