Reduce usage.

@param string $feature
@param int $uses
@return \Gerardojbaez\Laraplans\Models\PlanSubscriptionUsage
970024
public function reduce($feature, $uses = 1)
    {
        $feature = new Feature($feature);

        $usage = $this->subscription
            ->usage()
            ->byFeatureCode($feature->getFeatureCode())
            ->first();

        if (is_null($usage)) {
            return false;
        }

        $usage->used = max($usage->used - $uses, 0);

        $usage->save();

        return $usage;
    }
1149825
public function serializeFeature(FeatureInterface $feature)
    {
        $return = [];

        $filters = $this->serializeFilterGroups($feature->getFilter()->getFilterGroups());
        if(!empty($filters)) {
            $return['filters'] = $filters;
        }

        $breaker = $this->serializeFilterGroups($feature->getBreaker()->getFilterGroups());
        if(!empty($breaker)) {
            $return['breaker'] = $breaker;
        }

        $values = $this->serializeValueBag($feature->getValue());
        if(!empty($values)) {
            $return['values'] = $values;
        }

        if(!$feature->isEnabled()){
            $return['enabled'] = false;
        }

        return $return;
    }
57664
public function add(array $useStatement)
    {
        foreach ($useStatement['aliases'] as $alias) {
            if (isset($alias['alias'])) {
                $this->aliases[$alias['alias']] = $alias['name'];
            } else {
                $parts = explode('\\', $alias['name']);
                $implicitAlias = $parts[\count($parts) - 1];
                $this->aliases[$implicitAlias] = $alias['name'];
            }
        }
    }
661170
public function enabled($feature)
    {
        $feature_value = $this->value($feature);

        if (is_null($feature_value)) {
            return false;
        }

        // If value is one of the positive words configured then the
        // feature is enabled.
        if (in_array(strtoupper($feature_value), config('laraplans.positive_words'))) {
            return true;
        }

        return false;
    }
583392
function(features) {
        if(!(OpenLayers.Util.isArray(features))) {
            features = [features];
        }
        for(var i=0; i<features.length; ++i) {
            delete this.features[features[i].id];
        }
        this.redraw();
    }
182837
protected static function _generateUses($uses)
    {
        if (!$uses) {
            return '';
        }
        $traits = [];
        foreach ((array) $uses as $use) {
            if (!trait_exists($use)) {
                throw new MissingImplementationException("Unexisting trait `{$use}`");
            }
            $traits[] = '\\' . ltrim($use, '\\');
        }
        return '    use ' . join(', ', $traits) . ';';
    }
446871
public function setFeature(\Dywee\ProductBundle\Entity\Feature $feature = null)
    {
        $this->feature = $feature;

        return $this;
    }
987775
public function hasFeature($feature)
    {
        return (isset($this->_aFeatures[$feature]) && !is_null($this->_aFeatures[$feature]));
    }
8811
private function _use() {
    $node = new UseDeclarationStatementNode();
    $this->mustMatch(T_USE, $node);
    $this->tryMatch(T_FUNCTION, $node, 'useFunction') || $this->tryMatch(T_CONST, $node, 'useConst');
    $declarations = new CommaListNode();
    do {
      $declarations->addChild($this->useDeclaration());
    } while ($this->tryMatch(',', $declarations));
    $node->addChild($declarations, 'declarations');
    $this->endStatement($node);
    return $node;
  }
842077
public function setUseSession($useSession)
    {
        $this->useSession = (bool)$useSession;
        if ($useSession) {
            SessionHandler::enable();
        } else {
            SessionHandler::disable();
        }
        return $this;
    }
1144071
public function isSupported(string $feature): bool
    {
        if (!array_key_exists($feature, $this->supported)) {
            if (!isset($this->features[$feature])) {
                throw new UndefinedFeatureException($feature);
            }

            $this->supported[$feature] =
                (bool) $this->features[$feature]($this);
        }

        return $this->supported[$feature];
    }
925616
public function getUsageCount(AssetInterface $asset)
    {
        $usageCount = 0;
        /** @var AssetUsageStrategyInterface $strategy */
        foreach ($this->getUsageStrategies() as $strategy) {
            $usageCount += $strategy->getUsageCount($asset);
        }

        return $usageCount;
    }
168628
public function update(FeaturesRequest $request, Feature $feature)
    {
        if ($request->has('name') && $feature->name != $request->get('name')) {
            event(new FeatureNameWasUpdated($feature, $request->get('name')));
        }

        $feature->update(
            $request->except('name')
        );

        return redirect()->route('features.edit', $feature)->with('status', trans('globals.success_text'));
    }
468001
public function removeValue(\Dywee\ProductBundle\Entity\FeatureValue $values)
    {
        $this->values->removeElement($values);
    }
800835
public function clearFeatureData($feature)
    {
        $feature = $this->get($feature);
        if ($feature) {
            $feature->setData(array());
            $this->save($feature);
        }
    }
629982
public function makeUse()
    {
        ++$this->used;

        if ($this->count > 0 && $this->count <= $this->used) {
            $this->enabled = false;
        }

        return $this;
    }
1004469
public function deactivatePercentage($featureName)
    {
        $feature = $this->getFeature($featureName);
        $feature->setPercentage(0);
        $this->saveFeature($feature);
    }