Skip to content

Commit

Permalink
Subscription alerts exclude inactive members
Browse files Browse the repository at this point in the history
  • Loading branch information
ajitbohra committed Jan 17, 2019
1 parent 495c583 commit 591f13f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,21 @@ class Subscription extends Model

public function scopeDashboardExpiring($query)
{
return $query->where('end_date', '<', Carbon::today()->addDays(7))->where('status', '=', \constSubscription::onGoing);
return $query
->with(['members' => function ($query) {
$query->where('status', '=', \constStatus::Active);
}])
->where('end_date', '<', Carbon::today()->addDays(7))
->where('status', '=', \constSubscription::onGoing);
}

public function scopeDashboardExpired($query)
{
return $query->where('status', '=', \constSubscription::Expired);
return $query
->with(['members' => function ($query) {
$query->where('status', '=', \constStatus::Active);
}])
->where('status', '=', \constSubscription::Expired);
}

public function scopeIndexQuery($query, $sorting_field, $sorting_direction, $drp_start, $drp_end)
Expand Down

0 comments on commit 591f13f

Please sign in to comment.