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

tptompkins's avatar

How to get the User's current plan in Spark?

Hey Guys,

I tried using the User->sparkPlan() method to get the user's current plan, but in testing I noticed that it doesn't return the Free plan if a user was previously on a paid plan and had canceled the plan. In that case, it continues to return the previous paid plan, not the free plan like I would expect.

Is there a different built in method I should be using to get the user's current plan? Or do I need to build my own version of sparkPlan() to get the true current plan?

0 likes
4 replies
jekinney's avatar

Does the canceled plan still with in the expiration time? And when it expires are you putting the user back to a free plan?

tptompkins's avatar

When the plan is cancelled, Stripe sends the callback and the subscription in the subscriptions table is updated with a new ends_at date / time. When the current date passes the ends_at date, the User->sparkPlan() still returns the expired plan, but the subscribed middleware returns false. For this reason, I would expect sparkPlan() to return the free plan but it doesn't so I'm not sure if this is a bug or if it's expected that we implement a process to move the user back to the free plan.

The doc block for the sparkPlan() method says:

/**
     * Get the Spark plan that corresponds with the given subscription.
     *
     * If they are not subscribed and a free plan exists, that will be returned.
     *
     * @param  string  $subscription
     * @return \Laravel\Spark\Plan|null
     */

So based on that description, I'm assuming that it's a bug.

2 likes
gmenaria's avatar

@tptompkins What happen is, when user cancel subscription, he is still using that plan until last subscription time is finished.

nicolasbistolfi's avatar

Try using:

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

This workinf for me as is checking the current billing plan directly on the user object.

Please or to participate in this conversation.