gerardojbaez / laraplans

SaaS style recurring plans for Laravel.
http://laraplans.readthedocs.io
MIT License
180 stars 81 forks source link

FindEndingPeriod does not account for canceled subscription #44

Closed samtoya closed 4 years ago

samtoya commented 5 years ago

/**

Potential Fix: -->

public function scopeFindEndingPeriod($query, $dayRange = 3) { $from = Carbon::now(); $to = Carbon::now()->addDays($dayRange);

    $query->whereBetween('ends_at', [$from, $to])->whereNull('canceled_at')->whereNull('canceled_immediately');
}
gerardojbaez commented 4 years ago

I've added two new Eloquent scopes for excluding canceled subscriptions:

Using findEndingPeriod($days)->excludeCanceled() or findEndingPeriod($days)->excludeImmediatelyCanceled() should do the trick.