1 | <?php |
||
13 | abstract class Element implements ElementInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $type; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $title; |
||
29 | |||
30 | /** |
||
31 | * @var bool |
||
32 | */ |
||
33 | protected $disabled = false; |
||
34 | |||
35 | /** |
||
36 | * @var mixed |
||
37 | */ |
||
38 | protected $defaultValue; |
||
39 | |||
40 | /** |
||
41 | * @var \Illuminate\Database\Eloquent\Model |
||
42 | */ |
||
43 | protected $model; |
||
44 | |||
45 | /** |
||
46 | * @var \Closure |
||
47 | */ |
||
48 | protected $mutator; |
||
49 | |||
50 | /** |
||
51 | * Element constructor. |
||
52 | * |
||
53 | * @param string $name |
||
54 | * @param string $title |
||
55 | */ |
||
56 | public function __construct(string $name, string $title) |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getType() |
||
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | public function getName() |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function setName(string $value) |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | public function getTitle() |
||
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public function setTitle(string $value) |
||
104 | |||
105 | public function save() |
||
111 | |||
112 | public function finishSave() |
||
116 | |||
117 | /** |
||
118 | * @param $value |
||
119 | */ |
||
120 | protected function setModelAttribute($value) |
||
128 | |||
129 | /** |
||
130 | * @return array|string |
||
131 | */ |
||
132 | protected function getValueFromRequest() |
||
136 | |||
137 | /** |
||
138 | * @return \Closure |
||
139 | */ |
||
140 | public function getMutator(): \Closure |
||
144 | |||
145 | /** |
||
146 | * @param \Closure $mutator |
||
147 | * @return $this |
||
148 | */ |
||
149 | public function setMutator(\Closure $mutator) |
||
155 | |||
156 | public function hasMutator() |
||
160 | |||
161 | /** |
||
162 | * @param mixed $value |
||
163 | * |
||
164 | * @return mixed |
||
165 | */ |
||
166 | protected function prepareValue($value) |
||
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | public function getModel() |
||
182 | |||
183 | /** |
||
184 | * @param \Illuminate\Database\Eloquent\Model $model |
||
185 | * @return $this |
||
186 | */ |
||
187 | public function setModel(Model $model) |
||
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | */ |
||
197 | public function getValue() |
||
201 | |||
202 | /** |
||
203 | * @return mixed |
||
204 | */ |
||
205 | protected function getValueFromModel() |
||
215 | |||
216 | /** |
||
217 | * @param mixed $value |
||
218 | * |
||
219 | * @return $this |
||
220 | */ |
||
221 | public function setDefaultValue($value) |
||
227 | |||
228 | /** |
||
229 | * @return mixed |
||
230 | */ |
||
231 | protected function getDefaultValue() |
||
235 | |||
236 | /** |
||
237 | * @return bool |
||
238 | */ |
||
239 | public function isDisabled() |
||
243 | |||
244 | /** |
||
245 | * @return $this |
||
246 | */ |
||
247 | public function setDisabled() |
||
253 | |||
254 | /** |
||
255 | * @return array |
||
256 | */ |
||
257 | public function toArray() |
||
266 | |||
267 | /** |
||
268 | * @return array|mixed |
||
269 | */ |
||
270 | public function jsonSerialize() |
||
274 | |||
275 | /** |
||
276 | * @param int $options |
||
277 | * @return string |
||
278 | */ |
||
279 | public function toJson($options = 0) |
||
283 | |||
284 | /** |
||
285 | * @return string |
||
286 | */ |
||
287 | public function __toString() |
||
291 | } |
||
292 |