yoeriboven
3 weeks ago
215
5
Laravel

Eager Loading not possible

Posted 3 weeks ago by yoeriboven

I'm using Laravel Cashier Paddle (docs - package) and having some issues on eager loading.

I'm accessing the user's subscription multiple times on my settings page. This results in a separate query for every access.

According to Laravel Debugbar I'm making the same subscriptions request nine times.

This is the culprit:

auth()->user()->subscription('default')

How to eager load this query? Using protected $with = ['subscriptions'] on the User actually adds a query.

Here's the line in the package.

Please sign in or create an account to participate in this conversation.