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

ahuininga's avatar

Call to undefined method Illuminate\Database\Query\Builder::user()

In the trait Laravel\Spark\Http\Controllers\Settings\Billing\SendsInvoiceNotifications is a method buildInvoiceMessage that calls $billable->user()->localInvoices() but the method user() doesn't exists causing this error: Call to undefined method Illuminate\Database\Query\Builder::user()

In my case $billable is an instance of the team model. It has a localInvoices method so $billable->localInvoices() should work instead of $billable->user()->localInvoices()

The original url called is /webhook/stripe with an invoice.payment_succeeded event.

I'm using a fresh install of spark 3.0.4

Is this a bug in spark, or did I configure something wrong?

0 likes
5 replies
ejdelmonico's avatar

I think you need to either refer to the spark user or Auth::user().

ahuininga's avatar

Thx for the reply.

I fixed it by extending the StripeWebhookController, and using my own trait where a changed $billable->user()->localInvoices() to $billable->localInvoices()

clay's avatar

strange, because the actual source code is $billable->localInvoices()... not $billable->user()->localInvoices()...

clay's avatar
clay
Best Answer
Level 20

ahh, a pull request was submitted 13 days ago that fixed this issue

Please or to participate in this conversation.