Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #94 from bpuig/hotfix_get_feature_remainings
Browse files Browse the repository at this point in the history
[Fix] Get feature remainings
  • Loading branch information
bpuig authored Sep 5, 2021
2 parents 99f6ad7 + 2fa79e0 commit cff7661
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Models/PlanSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public function scopeGetByTag(Builder $builder, string $tag): Builder
{
return $builder->where('tag', $tag);
}

/**
* Set new subscription period.
*
Expand Down Expand Up @@ -656,11 +656,13 @@ public function getFeatureUsage(string $featureTag): int
*
* @param string $featureTag
*
* @return int
* @return int|null
*/
public function getFeatureRemainings(string $featureTag): int
public function getFeatureRemainings(string $featureTag): ?int
{
return $this->getFeatureValue($featureTag) - $this->getFeatureUsage($featureTag);
$featureValue = $this->getFeatureValue($featureTag);

return (is_numeric($featureValue)) ? $featureValue - $this->getFeatureUsage($featureTag) : null;
}

/**
Expand Down

0 comments on commit cff7661

Please sign in to comment.