/** * Handle the select options. * * @param TagsFieldType $fieldType */ public function handle(TagsFieldType $fieldType) { $options = (array) array_get($fieldType->getConfig(), 'options', []); if (is_string($options)) { $options = $this->dispatch(new ParseOptions($options)); } if ($options instanceof Collection && $options->isEmpty()) { $options = []; } if ($options instanceof Collection && is_object($first = $options->first())) { if ($first instanceof EntryInterface) { $value = $first->getTitleName(); } else { $value = 'id'; } $options = $options->lists($value); } if ($options instanceof Collection && is_string($options->first())) { $options = $options->all(); } $fieldType->setOptions($options); }
/** * Return the tags wrapped in labels. * * @param string $class * @return string */ public function labels($class = 'label-default') { return implode(' ', array_map(function ($tag) use($class) { return '<span class="label ' . $class . '">' . $tag . '</span>'; }, $this->object->getValue())); }
/** * Handle the command. * * @param Container $container */ public function handle(Container $container) { $container->call(array_get($this->fieldType->getConfig(), 'handler'), ['fieldType' => $this->fieldType]); }