Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

StefanRusu's avatar

Can't fetch user plan after user upgraded

Hi,

I'm working with Spark (for the first time) and I got a bit confused about retrieving user's current plan.

I'm currently doing the following:

$plan = Spark::plans()->where('id', $user->current_billing_plan)->first();

It works great until the user upgrades the plan. Once he upgraded $plan doesn't feature the new selected plan. It remains the same, although user upgraded to a different plan.

Any clarification on this would be great.

0 likes
5 replies
MichalOravec's avatar

Order it to get just latest plan.

$plan = Spark::plans()->where('id', $user->current_billing_plan)->latest()->first();

->latest() use as a default created_at column.

StefanRusu's avatar

Hi Michal,

Thank you for taking your time to help.

I'm afraid that the query only returns 1 plan...which is strange.

It should've returned 2 right? The plan that the user was first on + the plan user upgraded to.

MichalOravec's avatar
Level 75

Oh yeah sorry for that. It's because ->where('id', $user->current_billing_plan).

Current plan you can also get with

$user->sparkPlan();
1 like

Please or to participate in this conversation.