/**
  * Return the currency symbol.
  *
  * @return string|null
  */
 public function symbol()
 {
     if (($key = $this->object->getValue()) === null) {
         return null;
     }
     return config('streams::currencies.supported.' . $key . '.symbol');
 }
 /**
  * Return the selection value.
  *
  * @return string|null
  */
 public function value()
 {
     $options = $this->object->getOptions();
     if (!($key = $this->object->getValue())) {
         return null;
     }
     return trans(array_get($options, $key));
 }
 /**
  * Handle the select options.
  *
  * @param SelectFieldType $fieldType
  * @return array
  */
 public function handle(SelectFieldType $fieldType)
 {
     $options = array_get($fieldType->getConfig(), 'options', []);
     if (is_string($options)) {
         $options = $this->dispatch(new ParseOptions($options));
     }
     return array_filter([null => $fieldType->getPlaceholder()] + $options);
 }
Exemplo n.º 4
0
 /**
  * Handle the options.
  *
  * @param SelectFieldType $fieldType
  * @param ThemeCollection $themes
  * @param Repository      $config
  * @param Filesystem      $files
  */
 public function handle(SelectFieldType $fieldType, ThemeCollection $themes, Repository $config, Filesystem $files)
 {
     $theme = $themes->get($config->get('streams::themes.standard'));
     $options = $files->allFiles($theme->getPath('resources/views/layouts'));
     $fieldType->setOptions(array_combine(array_map(function ($path) use($theme) {
         return 'theme::' . ltrim(str_replace($theme->getPath('resources/views'), '', $path), '/');
     }, $options), array_map(function ($path) use($theme) {
         return ltrim(str_replace($theme->getPath('resources/views/layouts'), '', $path), '/');
     }, $options)));
 }
 /**
  * Handle the select options.
  *
  * @param SelectFieldType $fieldType
  * @return array
  */
 public function handle(SelectFieldType $fieldType, Container $container)
 {
     $options = array_get($fieldType->getConfig(), 'options', []);
     if (is_string($options)) {
         $options = $this->dispatch(new ParseOptions($options));
     }
     if ($options instanceof \Closure) {
         $options = $container->call($options);
     }
     $fieldType->setOptions($options);
 }
Exemplo n.º 6
0
 /**
  * Handle the command.
  *
  * @param Container $container
  */
 public function handle(Container $container)
 {
     $handler = array_get($this->fieldType->getConfig(), 'handler');
     if (!class_exists($handler) && !str_contains($handler, '@')) {
         $handler = array_get($this->fieldType->getHandlers(), $handler);
     }
     if (is_string($handler) && !str_contains($handler, '@')) {
         $handler .= '@handle';
     }
     $container->call($handler, ['fieldType' => $this->fieldType]);
 }
Exemplo n.º 7
0
 /**
  * Handle the options.
  *
  * @param SelectFieldType $fieldType
  */
 public function handle(SelectFieldType $fieldType)
 {
     $years = [];
     $start = (new Carbon())->createFromTimestamp(strtotime($fieldType->config('start', '-10 years')))->format('Y');
     $end = (new Carbon())->createFromTimestamp(strtotime($fieldType->config('end', 'now')))->format('Y');
     for ($date = $start; $date <= $end; $date++) {
         $years[$date] = $date;
     }
     if (strtolower($fieldType->config('sort', 'desc')) == 'desc') {
         $years = array_reverse($years);
     }
     $fieldType->setOptions(array_combine($years, $years));
 }
Exemplo n.º 8
0
 /**
  * Handle the options.
  *
  * @param SelectFieldType $fieldType
  */
 public function handle(SelectFieldType $fieldType)
 {
     $fieldType->setOptions(array_combine(timezone_identifiers_list(), timezone_identifiers_list()));
 }
Exemplo n.º 9
0
 /**
  * Handle the options.
  *
  * @param SelectFieldType $fieldType
  * @param Repository      $config
  */
 public function handle(SelectFieldType $fieldType, Repository $config)
 {
     $currencies = array_values($config->get('streams::currencies.enabled'));
     $fieldType->setOptions(array_combine($currencies, $currencies));
 }