| @@ 167-188 (lines=22) @@ | ||
| 164 | ||
| 165 | $options = $options->get(); |
|
| 166 | ||
| 167 | if (is_callable($makeDisplay = $this->getDisplay())) { |
|
| 168 | // make dynamic display text |
|
| 169 | if ($options instanceof Collection) { |
|
| 170 | $options = $options->all(); |
|
| 171 | } |
|
| 172 | ||
| 173 | // iterate for all options and redefine it as |
|
| 174 | // list of KEY and TEXT pair |
|
| 175 | $options = array_map(function ($opt) use ($key, $makeDisplay) { |
|
| 176 | // get the KEY and make the display text |
|
| 177 | return [data_get($opt, $key), $makeDisplay($opt)]; |
|
| 178 | }, $options); |
|
| 179 | ||
| 180 | // take options as array with KEY => VALUE pair |
|
| 181 | $options = array_pluck($options, 1, 0); |
|
| 182 | } elseif ($options instanceof Collection) { |
|
| 183 | // take options as array with KEY => VALUE pair |
|
| 184 | $options = array_pluck($options->all(), $this->getDisplay(), $key); |
|
| 185 | } else { |
|
| 186 | // take options as array with KEY => VALUE pair |
|
| 187 | $options = array_pluck($options, $this->getDisplay(), $key); |
|
| 188 | } |
|
| 189 | ||
| 190 | return $options; |
|
| 191 | } |
|
| @@ 225-246 (lines=22) @@ | ||
| 222 | ||
| 223 | $options = $options->get(); |
|
| 224 | ||
| 225 | if (is_callable($makeDisplay = $this->getDisplay())) { |
|
| 226 | // make dynamic display text |
|
| 227 | if ($options instanceof Collection) { |
|
| 228 | $options = $options->all(); |
|
| 229 | } |
|
| 230 | ||
| 231 | // iterate for all options and redefine it as |
|
| 232 | // list of KEY and TEXT pair |
|
| 233 | $options = array_map(function ($opt) use ($key, $makeDisplay) { |
|
| 234 | // get the KEY and make the display text |
|
| 235 | return [data_get($opt, $key), $makeDisplay($opt)]; |
|
| 236 | }, $options); |
|
| 237 | ||
| 238 | // take options as array with KEY => VALUE pair |
|
| 239 | $options = array_pluck($options, 1, 0); |
|
| 240 | } elseif ($options instanceof Collection) { |
|
| 241 | // take options as array with KEY => VALUE pair |
|
| 242 | $options = array_pluck($options->all(), $this->getDisplay(), $key); |
|
| 243 | } else { |
|
| 244 | // take options as array with KEY => VALUE pair |
|
| 245 | $options = array_pluck($options, $this->getDisplay(), $key); |
|
| 246 | } |
|
| 247 | ||
| 248 | return $options; |
|
| 249 | } |
|