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

eugenefvdm's avatar

Laravel Cashier: How to get a list of all active subscribers?

In my application a user can only have one active subscription. I'm using the stock \App\Models\User::class as my cashier model.

How can I get a list of all users who have active subscriptions?

The context is I need to perform a mass operation but only on users who have active subscriptions. It can be "paid up" or on trial, as long as it's active.

I am aware I can do this per user:

$user->subscribed('default');

Of course I can loop over the data but the User model appears to morph somehow to Subscription which probably means with something like map or has I might be able to accomplish something much more efficient.

Just need a few pointers if possible.

0 likes
2 replies
DavidS.'s avatar

Not sure how to do both at the same time.

This will get all current subscriptions.

Laravel\Cashier\Subscription::query()->active()->get();
bojan_s's avatar

The code below fetches all users who have an active subscription

   $subscribers = User::query()->whereHas('subscriptions', function (Builder $query) {
            $query->active();
        })->get();

Please or to participate in this conversation.