lucasdotvin/laravel-soulbscription

Unable to get the plan of the expired subscription

LuanHimmlisch opened this issue ยท 3 comments

I think this is deliberate (or I may be missing some functionality), but I must report it because it makes working with this package a lot harder that it should.

Once a subscription has ended, it stops retrieving it and returns null. What if I want to access the plan of the expired subscription? Currently, it's not possible because you just get a null.

The documentation doesn't mention anything about renewing a subscription, how do I renew a subscription that is null?

Hey, Luan! Thanks for bringing up this question! I tried to get the last subscription here, but it was only possible by querying them using the Subscription model:

Subscription::whereMorphedTo('subscriber', $subscriber)
    ->withExpired()
    ->orderBy('started_at', 'desc')
    ->first();

I did not like this way, so I'm working on a method to retrieve the last expired subscription with a simple call, like $subscriber->lastSubscription. I'll make a comment here when it is done. ๐Ÿš€

Thanks a lot @lucasdotvin

Hi! The method lastSubscription was published in the last release (v2.4) and documented on the README.md file. Let me know if I can help you in any other way! ๐Ÿค˜