| @@ 58-68 (lines=11) @@ | ||
| 55 | ||
| 56 | public function getOptions() |
|
| 57 | { |
|
| 58 | if ($this->options instanceof \Closure) { |
|
| 59 | $options = ($this->options)(); |
|
| 60 | } elseif (is_string($this->options) || $this->options instanceof Model) { |
|
| 61 | $options = $this->setOptionsFromModel(); |
|
| 62 | } elseif (is_array($this->options)) { |
|
| 63 | $options = $this->options; |
|
| 64 | } else { |
|
| 65 | throw new InvalidArgumentException( |
|
| 66 | "The form select element's options must be return array(key=>value)" |
|
| 67 | ); |
|
| 68 | } |
|
| 69 | ||
| 70 | return collect($options)->mapWithKeys(function ($value, $key) { |
|
| 71 | return [ |
|
| @@ 86-96 (lines=11) @@ | ||
| 83 | ||
| 84 | public function getNodes() |
|
| 85 | { |
|
| 86 | if ($this->nodes instanceof \Closure) { |
|
| 87 | $nodes = ($this->nodes)(); |
|
| 88 | } elseif (is_string($this->nodes) || $this->nodes instanceof Model) { |
|
| 89 | $nodes = $this->setNodesFromModel(); |
|
| 90 | } elseif (is_array($this->nodes)) { |
|
| 91 | $nodes = $this->nodes; |
|
| 92 | } else { |
|
| 93 | throw new InvalidArgumentException( |
|
| 94 | "The form tree element's nodes must be return array" |
|
| 95 | ); |
|
| 96 | } |
|
| 97 | ||
| 98 | return $nodes; |
|
| 99 | } |
|