@@ 13-29 (lines=17) @@ | ||
10 | { |
|
11 | protected $defaultValue = []; |
|
12 | ||
13 | public function getValue() |
|
14 | { |
|
15 | $value = $this->getValueFromModel(); |
|
16 | if (empty($value)) { |
|
17 | return $value; |
|
18 | } |
|
19 | ||
20 | if ($this->isOptionsModel() && $this->isRelation()) { |
|
21 | $model = $this->getOptionsModel(); |
|
22 | $key = $this->getOptionsValueAttribute() ?: $model->getKeyName(); |
|
23 | ||
24 | $value = $value->pluck($key)->map(function ($item) { |
|
25 | return (string)$item; |
|
26 | }); |
|
27 | } |
|
28 | return $value; |
|
29 | } |
|
30 | ||
31 | public function save() |
|
32 | { |
@@ 23-39 (lines=17) @@ | ||
20 | $this->setOptions($options); |
|
21 | } |
|
22 | ||
23 | public function getValue() |
|
24 | { |
|
25 | $value = $this->getValueFromModel(); |
|
26 | if (empty($value)) { |
|
27 | return $value; |
|
28 | } |
|
29 | ||
30 | if ($this->isOptionsModel() && $this->isRelation()) { |
|
31 | $model = $this->getOptionsModel(); |
|
32 | $key = $this->getOptionsValueAttribute() ?: $model->getKeyName(); |
|
33 | ||
34 | $value = $value->pluck($key)->map(function ($item) { |
|
35 | return (string)$item; |
|
36 | }); |
|
37 | } |
|
38 | return $value; |
|
39 | } |
|
40 | ||
41 | public function save() |
|
42 | { |