Determine if the model has any the given widgets.

@param int|string|array|\ArrayAccess|WidgetModelContract $widgets

@return bool
498514
public function hasWidget($widgets): bool
    {
        // Single Widget id
        if (is_string($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget id
        if (is_int($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget model
        if ($widgets instanceof WidgetModelContract) {
            return $this->widgets->contains('id', $widgets->id);
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_string($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_int($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Collection of Widget models
        if ($widgets instanceof Collection) {
            return ! $widgets->intersect($this->widgets->pluck('id'))->isEmpty();
        }

        return false;
    }
748017
public static function orderByPreference($widgets)
    {
        $preference = collect(['laralum', 'dashboard', 'users', 'roles', 'permissions']);

        $ordered_widgets = [];
        $final_ordered_widgets = [];

        $widgets = collect($widgets)->groupBy('package')->toArray();

        foreach (Packages::all() as $package) {
            if (!in_array($package, $preference->toArray())) {
                $preference->push($package);
            }
        }

        $ordered_widgets = $preference->map(function ($p) use ($widgets) {
            return array_key_exists($p, $widgets) ? $widgets[$p] : null;
        })->filter();

        foreach ($ordered_widgets as $widget) {
            foreach ($widget as $w) {
                array_push($final_ordered_widgets, $w);
            }
        }

        return $final_ordered_widgets;
    }
401085
public function has($keys)
    {
        $keys = is_array($keys) ? $keys : func_get_args();

        $results = $this->payload();

        foreach ($keys as $value) {
            if ($this->hasValueAtKey($value, $results) === false) {
                return false;
            }
        }
        return true;
    }
617954
public function addWidgets( $widget, $services )
    {
        foreach ( $services as $key => $description )
        {
            if ( null === $description || is_scalar( $description ) )
            {
                $service    = $key;
                $priority   = null === $description ? null : (int) $description;
            }
            else
            {
                if ( $description instanceof \Traversable )
                {
                    $description = iterator_to_array( $description );
                }
                else if ( ! $description instanceof \ArrayAccess )
                {
                    $description = (array) $description;
                }

                if ( ! isset( $description['service'] ) )
                {
                    continue;
                }

                $service = $description['service'];

                if ( isset( $description['priority'] ) )
                {
                    $priority = (int) $description['priority'];
                }
                else
                {
                    $priority = null;
                }
            }

            $this->addWidget( $widget, $service, $priority );
        }

        return $this;
    }
78893
public function isEnabled(Widget $widget)
    {
        $widgets = $this->container->getParameter('victoire_core.widgets');
        foreach ($widgets as $widgetParams) {
            if ($widgetParams['class'] === ClassUtils::getClass($widget)) {
                return true;
            }
        }

        return false;
    }
905025
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
    public static boolean hasAppWidgetFeature(PackageManager manager) {
        return manager.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS);
    }
978637
protected function ___attainWidgetInstance($widget)
    {
        /** @var $widgetManager WidgetManager */
        $widgetManager = $this->sm->get('yimaWidgetator.WidgetManager');

        $options = [];
        if (is_array($widget)) {
            $wArg    = $widget;
            $widget  = $wArg['widget'];
            $options = (isset($wArg['params'])) ? $wArg['params'] : $options;
        }

        $instance = $widgetManager->get($widget, $options);

        return $instance;
    }
661446
public function has_all(array $keys) {
        foreach ($keys as $key) {
            if (!is_array($key)) {
                $key = array('key' => $key);
            }
            $key = $key['key'];
            if (!isset($this->store[$key])) {
                return false;
            }
        }
        return true;
    }
32159
public function addWidget($widget)
    {
        $this->widgets->add($widget); 
        $this->layoutWidget($widget);
        return $this;
    }
1344092
public boolean isSingleWidget(String widgetId) {
		try {
			WidgetState state = (WidgetState) storageService.getEntityById(widgetId);
			DashboardState dState = getDashboardState(state);
			if (dState.getColumnCount() > 1) {
				return false;
			}
			if (dState.getWidgetStates().size() > 1) {
				return false;
			}
			return true;
		} catch (NotFoundException e) {
			return false;
		}
	}
1300226
public function isWidgetAllowedForSlot(Widget $widget, $slot)
    {
        $widgetName = $this->getWidgetName($widget);
        $slots = $this->slots;

        return !empty($slots[$slot]) && (array_key_exists($widgetName, $slots[$slot]['widgets']));
    }
1273617
private function getModelFromWidget(Widget $widget)
    {
        if ($widget->dataContainer) {
            return $widget->dataContainer->getModel();
        }

        return $widget->getModel();
    }
28728
public function hasOptions(array $options) {
        $all = true;

        foreach ($options as $option) {
            if (!isset($this->_options[$option])) {
                $all = false;
            }
        }

        return $all;
    }
224303
public function setWidgetsAttribute($widgets)
    {
        if (! $this->exists) {
            $this->queuedWidgets = $widgets;

            return;
        }

        $this->attachWidgets($widgets);
    }
128676
def is_widget_required_attribute(widget):
    
    if not widget.is_required:
        return False
    if isinstance(widget, WIDGETS_NO_REQUIRED):
        return False
    return True
1340727
function (widgets) {

          if (!this.storage) {
            return true;
          }

          var serialized = _.map(widgets, function (widget) {
            var widgetObject = {
              title: widget.title,
              name: widget.name,
              style: widget.style,
              dataModelOptions: widget.dataModelOptions,
              storageHash: widget.storageHash,
              attrs: widget.attrs
            };

            return widgetObject;
          });

          var item = { widgets: serialized, hash: this.hash };

          if (this.stringify) {
            item = JSON.stringify(item);
          }

          this.storage.setItem(this.id, item);
          return true;
        }
332564
public function widgetExist($name)
    {
        $name = strtolower($name);

        return isset($this->dataStore[0][$name]) ? $this->dataStore[0][$name] : false;
    }