| @@ 30-40 (lines=11) @@ | ||
| 27 | */ |
|
| 28 | public function getOptions() |
|
| 29 | { |
|
| 30 | if ($this->options instanceof \Closure) { |
|
| 31 | $options = ($this->options)(); |
|
| 32 | } elseif (is_string($this->options) || $this->options instanceof Model) { |
|
| 33 | $options = $this->getOptionsFromModel(); |
|
| 34 | } elseif (is_array($this->options)) { |
|
| 35 | $options = $this->options; |
|
| 36 | } else { |
|
| 37 | throw new InvalidArgumentException( |
|
| 38 | "The select options must be return array(key=>value)" |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | ||
| 42 | return collect($options)->mapWithKeys(function ($value, $key) { |
|
| 43 | return [ |
|
| @@ 63-73 (lines=11) @@ | ||
| 60 | ||
| 61 | public function getOptions() |
|
| 62 | { |
|
| 63 | if ($this->options instanceof \Closure) { |
|
| 64 | $options = ($this->options)(); |
|
| 65 | } elseif (is_string($this->options) || $this->options instanceof Model) { |
|
| 66 | $options = $this->getOptionsFromModel(); |
|
| 67 | } elseif (is_array($this->options)) { |
|
| 68 | $options = $this->options; |
|
| 69 | } else { |
|
| 70 | throw new InvalidArgumentException( |
|
| 71 | "The form select element's options must be return array(key=>value)" |
|
| 72 | ); |
|
| 73 | } |
|
| 74 | ||
| 75 | $this->extraOptions->each(function ($value, $key) use ($options) { |
|
| 76 | $options[$key] = $value; |
|
| @@ 85-95 (lines=11) @@ | ||
| 82 | ||
| 83 | public function getNodes() |
|
| 84 | { |
|
| 85 | if ($this->nodes instanceof \Closure) { |
|
| 86 | $nodes = ($this->nodes)(); |
|
| 87 | } elseif (is_string($this->nodes) || $this->nodes instanceof Model) { |
|
| 88 | $nodes = $this->setNodesFromModel(); |
|
| 89 | } elseif (is_array($this->nodes)) { |
|
| 90 | $nodes = $this->nodes; |
|
| 91 | } else { |
|
| 92 | throw new InvalidArgumentException( |
|
| 93 | "The form tree element's nodes must be return array" |
|
| 94 | ); |
|
| 95 | } |
|
| 96 | ||
| 97 | return $nodes; |
|
| 98 | } |
|