| @@ 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 | protected function isOptionsModel() |
|
| 32 | { |
|
| @@ 28-44 (lines=17) @@ | ||
| 25 | $this->setOptions($options); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function getValue() |
|
| 29 | { |
|
| 30 | $value = $this->getValueFromModel(); |
|
| 31 | if (empty($value)) { |
|
| 32 | return $value; |
|
| 33 | } |
|
| 34 | ||
| 35 | if ($this->isOptionsModel() && $this->isRelation()) { |
|
| 36 | $model = $this->getOptionsModel(); |
|
| 37 | $key = $this->getOptionsValueAttribute() ?: $model->getKeyName(); |
|
| 38 | ||
| 39 | $value = $value->pluck($key)->map(function ($item) { |
|
| 40 | return (string)$item; |
|
| 41 | }); |
|
| 42 | } |
|
| 43 | return $value; |
|
| 44 | } |
|
| 45 | ||
| 46 | protected function isOptionsModel() |
|
| 47 | { |
|