1 | <?php |
||
14 | abstract class Field |
||
15 | { |
||
16 | use FieldHasUiModifiers; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | const TYPE = 'type'; |
||
22 | |||
23 | /** |
||
24 | * @var CrudFields |
||
25 | */ |
||
26 | protected $fields; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $identifier; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $rules; |
||
37 | |||
38 | /** |
||
39 | * Field constructor. |
||
40 | * |
||
41 | * @param string $identifier |
||
42 | * @param array|string $rules |
||
43 | */ |
||
44 | public function __construct($identifier, $rules = null) |
||
53 | |||
54 | /** |
||
55 | * Constructs staticly. |
||
56 | * |
||
57 | * @param string $idenfitier |
||
58 | * @param null|string|array $rules |
||
59 | * @return static |
||
60 | */ |
||
61 | public static function handle($idenfitier, $rules = null) |
||
65 | |||
66 | |||
67 | /** |
||
68 | * Add validation rules to the field. |
||
69 | * |
||
70 | * @param string|array $rules |
||
71 | * @return mixed |
||
72 | */ |
||
73 | public function withRules($rules) |
||
99 | |||
100 | /** |
||
101 | * Add a validation rule. |
||
102 | * |
||
103 | * @param string $rule |
||
104 | * @return self |
||
105 | */ |
||
106 | public function addRule($rule) |
||
112 | |||
113 | /** |
||
114 | * @param CrudFields $fields |
||
115 | * @return self |
||
116 | */ |
||
117 | public function setFields(CrudFields $fields) |
||
123 | |||
124 | /** |
||
125 | * Get the field identifier. |
||
126 | * |
||
127 | * @param void |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getIdentifier() |
||
134 | |||
135 | /** |
||
136 | * Render the field form. |
||
137 | * |
||
138 | * @param void |
||
139 | * @return string |
||
140 | */ |
||
141 | public function form() |
||
145 | |||
146 | /** |
||
147 | * Get the form view. |
||
148 | * |
||
149 | * @param void |
||
150 | * @return View |
||
151 | */ |
||
152 | protected function getForm() |
||
156 | |||
157 | /** |
||
158 | * Get the field view name. |
||
159 | * |
||
160 | * @param void |
||
161 | * @return string |
||
162 | */ |
||
163 | abstract public function getViewName(); |
||
164 | |||
165 | /** |
||
166 | * Returns additionnal variables to the views. |
||
167 | * |
||
168 | * @param void |
||
169 | * @return array |
||
170 | */ |
||
171 | protected function getViewVariables() |
||
175 | |||
176 | /** |
||
177 | * Returns all base variables for the view. |
||
178 | * |
||
179 | * @param void |
||
180 | * @return array |
||
181 | */ |
||
182 | protected function getViewBaseVariables() |
||
200 | |||
201 | /** |
||
202 | * Checks if the field has an error. |
||
203 | * |
||
204 | * @param void |
||
205 | * @return bool |
||
206 | */ |
||
207 | public function hasError() |
||
211 | |||
212 | /** |
||
213 | * Returns the error. |
||
214 | * |
||
215 | * @param void |
||
216 | * @return null|string |
||
217 | */ |
||
218 | public function getError() |
||
227 | |||
228 | /** |
||
229 | * Checks if the field has a previous value. |
||
230 | * |
||
231 | * @param void |
||
232 | * @return bool |
||
233 | */ |
||
234 | public function hasOld() |
||
238 | |||
239 | /** |
||
240 | * Returns the old value. |
||
241 | * |
||
242 | * @param void |
||
243 | * @return string|null |
||
244 | */ |
||
245 | public function getOld() |
||
254 | |||
255 | /** |
||
256 | * Get the field value. |
||
257 | * |
||
258 | * @param void |
||
259 | * @return mixed |
||
260 | */ |
||
261 | public function getValue() |
||
270 | |||
271 | /** |
||
272 | * Get the value to be displayed on a table. |
||
273 | * |
||
274 | * @param void |
||
275 | * @return mixed |
||
276 | */ |
||
277 | public function getTableValue() |
||
281 | |||
282 | /** |
||
283 | * Set a new value to the model. |
||
284 | * |
||
285 | * @param mixed $value |
||
286 | * @return self |
||
287 | */ |
||
288 | public function newValue($value) |
||
294 | |||
295 | /** |
||
296 | * @param void |
||
297 | * @return string |
||
298 | */ |
||
299 | public function getRules() |
||
303 | } |
||
304 |
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: