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

[Fix] Get feature remainings #94

Merged
merged 1 commit into from
Sep 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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