Get user subscription limits

Laraship QuestionsCategory: TechnicalGet user subscription limits
matt asked 4 years ago
I have a plan with a feature called 'cards' that is set to type quantity. How do I get this value based on the current user? For example, if the current user is subscribed to the 'Silver' plan that has a 'cards' quantity of '5', how do I get that value so I can use it? Thanks
matt replied 4 years ago

Hello?

laraship Staff replied 4 years ago

Hello Matt, Usage-based tracking feature is not available, we are happy to add it as customization service, please email us at info@corals.io for quote.

matt replied 4 years ago

Hi. I don’t want to track the usage, I just want to know what the feature value is.

OK, let me ask it another way:

How can I check what subscription the current user has?

Once I know what subscription the current user has, how do I return the features of that subscription plan?

Can I return the features of the plan as an array for example?

1 Answers
Best Answer
laraship Staff answered 4 years ago

Hello,
Since users can have multiple subscriptions, first you need to get active subsctipnions
foreach(user()->activeSubscriptions() as $subscription){
$plan = $subsctiption->plan;
$plan_feature = $plan->features()->where(‘feature_id’, YOUR_FEATURE_ID )->first()?: null;
$value = $plan_feature->pivot->value;

}
}

matt replied 4 years ago

Can you update this question please? The code you provided has gone missing!

Thank you.

harter patrick replied 4 years ago

Can you update this question please? The code you provided has gone missing!

Thank you.

matt replied 4 years ago

Can you update this question please? The code you provided has gone missing!

Thank you.

laraship Staff replied 4 years ago

hello.

A comment is showing now, thanks