1 | <?php |
||
14 | abstract class Element implements ElementInterface |
||
15 | { |
||
16 | use HasCast; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $type; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $name; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $title; |
||
32 | |||
33 | /** |
||
34 | * @var mixed |
||
35 | */ |
||
36 | protected $defaultValue; |
||
37 | |||
38 | /** |
||
39 | * @var \Illuminate\Database\Eloquent\Model |
||
40 | */ |
||
41 | protected $model; |
||
42 | |||
43 | /** |
||
44 | * @var \Closure |
||
45 | */ |
||
46 | protected $mutator; |
||
47 | |||
48 | /** |
||
49 | * Element constructor. |
||
50 | * |
||
51 | * @param string $name |
||
52 | * @param string $title |
||
53 | */ |
||
54 | public function __construct(string $name, string $title) |
||
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getType() |
||
66 | |||
67 | /** |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getName() |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public function setName(string $value) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function getTitle() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function setTitle(string $value) |
||
102 | |||
103 | public function save() |
||
109 | |||
110 | public function finishSave() |
||
114 | |||
115 | /** |
||
116 | * @param $value |
||
117 | * @return Model |
||
118 | */ |
||
119 | protected function setModelAttribute($value) |
||
127 | |||
128 | /** |
||
129 | * @return array|string |
||
130 | */ |
||
131 | protected function getValueFromRequest() |
||
135 | |||
136 | /** |
||
137 | * @return null|\Closure |
||
138 | */ |
||
139 | public function getMutator() |
||
143 | |||
144 | /** |
||
145 | * @param \Closure $mutator |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function setMutator(\Closure $mutator) |
||
154 | |||
155 | public function hasMutator() |
||
159 | |||
160 | /** |
||
161 | * @param mixed $value |
||
162 | * |
||
163 | * @return mixed |
||
164 | */ |
||
165 | protected function prepareValue($value) |
||
188 | |||
189 | /** |
||
190 | * {@inheritdoc} |
||
191 | */ |
||
192 | public function getModel() |
||
196 | |||
197 | /** |
||
198 | * @param \Illuminate\Database\Eloquent\Model $model |
||
199 | * @return $this |
||
200 | */ |
||
201 | public function setModel(Model $model) |
||
207 | |||
208 | /** |
||
209 | * {@inheritdoc} |
||
210 | */ |
||
211 | public function getValue() |
||
225 | |||
226 | /** |
||
227 | * @return mixed |
||
228 | */ |
||
229 | protected function getValueFromModel() |
||
236 | |||
237 | /** |
||
238 | * @param mixed $value |
||
239 | * |
||
240 | * @return $this |
||
241 | */ |
||
242 | public function setDefaultValue($value) |
||
248 | |||
249 | /** |
||
250 | * @return mixed |
||
251 | */ |
||
252 | protected function getDefaultValue() |
||
256 | |||
257 | /** |
||
258 | * @return array |
||
259 | */ |
||
260 | public function toArray() |
||
268 | |||
269 | /** |
||
270 | * @return array|mixed |
||
271 | */ |
||
272 | public function jsonSerialize() |
||
276 | |||
277 | /** |
||
278 | * @param int $options |
||
279 | * @return string |
||
280 | */ |
||
281 | public function toJson($options = 0) |
||
285 | |||
286 | /** |
||
287 | * @return string |
||
288 | */ |
||
289 | public function __toString() |
||
293 | } |
||
294 |