-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Usage seems to be wrong #30
Comments
+1 @jimiero Any solution? I have the same issue and am looking for a workaround or fix. If you've found a solution, could you please share the steps or code changes you used? Thanks in advance! 🙏 . |
@JELmzabi unfortunately, I haven't because I'm also expecting to see if this package is maintained if not I'd rather using different one @mckenziearts do you have any input |
I think we should initialize usage. I have created a function that does that, but I’m not sure if it’s the best solution. public function initializeSubscriptionUsage(Subscription $subscription) {
$features = $subscription->plan->features;
$usages = [];
foreach ($features as $feature) {
$featureValue = $feature->value;
if(is_numeric($featureValue) && $featureValue != '0') {
$usages[]= [
'subscription_id' => $subscription->getKey(),
'feature_id' => $feature->getKey(),
'used' => 0,
];
}
}
return $subscription->usage()->createMany($usages);
} |
@JELmzabi where did you put that method? |
@jimiero in a service |
@JELmzabi a bit more details? when exactly do you initialize it ? |
@jimiero When a user subscribes to a plan, I initialize their usage |
@JELmzabi do you have discord or something where we can discuss? |
Hello @mckenziearts ,
I think this method here may be wrong
why will it fail if there's not usages done already ?
lets say user purchase a plan with feature "contacts" with limit 30
Then if you do
it will return false, because he never made use of that feature...
The text was updated successfully, but these errors were encountered: