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

masonfox's avatar

Spark Cashier IncrementQuantity Error

I am attempting to use the incrementQuantity approach with Stripe. Using like this:

$user = User::find($request->user()->id);
$user->subscription('employer')->incrementQuantity();

I get this error whenever I run it:

Call to a member function incrementQuantity() on null

Any help is appreciated!

0 likes
3 replies
bobbybouwmann's avatar

$user->subscription('employer') returns NULL, you need to check that first

masonfox's avatar

This returns a collection though?:

$user = User::find($request->user()->id);
$user->subscriptions()->get();

If I try and run (adding an s to subscription):

$user->subscriptions('employer')->incrementQuantity();

It throws the following because that certainly isn't the right method:

Call to undefined method Illuminate\Database\Query\Builder::incrementQuantity()
masonfox's avatar
masonfox
OP
Best Answer
Level 3

I ended up finding it. You don't need to specify a plan for the method, you can just say:

$user->subscription()->incrementQuantity();

Although the official docs show a plan, which throws the error I received.

1 like

Please or to participate in this conversation.