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 | */ |
||
118 | protected function setModelAttribute($value) |
||
126 | |||
127 | /** |
||
128 | * @return array|string |
||
129 | */ |
||
130 | protected function getValueFromRequest() |
||
134 | |||
135 | /** |
||
136 | * @return null|\Closure |
||
137 | */ |
||
138 | public function getMutator() |
||
142 | |||
143 | /** |
||
144 | * @param \Closure $mutator |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function setMutator(\Closure $mutator) |
||
153 | |||
154 | public function hasMutator() |
||
158 | |||
159 | /** |
||
160 | * @param mixed $value |
||
161 | * |
||
162 | * @return mixed |
||
163 | */ |
||
164 | protected function prepareValue($value) |
||
180 | |||
181 | /** |
||
182 | * {@inheritdoc} |
||
183 | */ |
||
184 | public function getModel() |
||
188 | |||
189 | /** |
||
190 | * @param \Illuminate\Database\Eloquent\Model $model |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setModel(Model $model) |
||
199 | |||
200 | /** |
||
201 | * {@inheritdoc} |
||
202 | */ |
||
203 | public function getValue() |
||
213 | |||
214 | /** |
||
215 | * @return mixed |
||
216 | */ |
||
217 | protected function getValueFromModel() |
||
227 | |||
228 | /** |
||
229 | * @param mixed $value |
||
230 | * |
||
231 | * @return $this |
||
232 | */ |
||
233 | public function setDefaultValue($value) |
||
239 | |||
240 | /** |
||
241 | * @return mixed |
||
242 | */ |
||
243 | protected function getDefaultValue() |
||
247 | |||
248 | /** |
||
249 | * @return array |
||
250 | */ |
||
251 | public function toArray() |
||
259 | |||
260 | /** |
||
261 | * @return array|mixed |
||
262 | */ |
||
263 | public function jsonSerialize() |
||
267 | |||
268 | /** |
||
269 | * @param int $options |
||
270 | * @return string |
||
271 | */ |
||
272 | public function toJson($options = 0) |
||
276 | |||
277 | /** |
||
278 | * @return string |
||
279 | */ |
||
280 | public function __toString() |
||
284 | } |
||
285 |