bpuig / laravel-subby

Laravel Plan and Subscriptions manager.
https://bpuig.github.io/laravel-subby
MIT License
104 stars 42 forks source link

Change plan or/and renew plan period #159

Open elephantux opened 1 year ago

elephantux commented 1 year ago

How do I change the plan for a user who already has an active plan and have the expiration dates updated based on the data from the new plan?

Everything is changing and updating with changePlan($plan) method except for the starts_at & ends_at dates.

elephantux commented 1 year ago

My solution:

$user->subscription()->changePlan($plan);
$user->subscription()->update([
    'starts_at' => null,
    'ends_at' => null
]);
$user->subscription()->renew();

But I don't think that's the right or best solution.