/** * @param OptionContract $option * * @return array */ protected function getItemClasses(OptionContract $option) { $classes = [$this->getBaseItemClass()]; if (!is_null($option->getValue())) { $classes[] = $this->getValueClass($option->getValue()); } if ($option->getFrequency() === 0) { $classes[] = $this->getMutedClass(); } if ($this->isActive($option)) { $classes[] = $this->getActiveClass(); } return $classes; }
/** * @param OptionContract $option * * @return array */ protected function getLinkParams(OptionContract $option) { $params = $this->params; unset($params[$this->id]); if (is_null($option->getValue())) { return $params; } if ($this->multiple) { $activeItems = []; foreach ($this->items as $item) { if ($item != $option && $item->isActive() || $item == $option && !$item->isActive()) { $activeItems[] = $item->getValue(); } } if ($activeItems) { $params[$this->id] = $activeItems; } } elseif (!$option->isActive()) { $params[$this->id] = $option->getValue(); } return $params; }
/** * @inheritDoc */ protected function renderOption(OptionContract $option) { return $this->html ? $option->getTitle() : e($option->getTitle()); }
/** * @param OptionContract $option * * @return bool */ public function isActive(OptionContract $option) { if ($option->isActive() !== null) { return $option->isActive(); } if (null === ($value = $option->getValue())) { return false; } if (!($input = $this->getRequest())) { return false; } $input = $input->get($this->id); return is_array($input) ? in_array($value, $input) : $value == $input; }