belongsTo(Member::class); } public function subscription() { return $this->belongsTo(Subscription::class); } public function status() { return $this->belongsTo(Status::class); } public function scopeWhereNeedsPayment($q) { return $q->whereHas('status', function($q) { return $q->needsPayment(); }); } public function scopeWhereNeedsBill($q) { return $q->whereHas('status', function($q) { return $q->where('is_bill', true); }); } public function scopeWhereNeedsRemember($q) { return $q->whereHas('status', function($q) { return $q->where('is_remember', true); })->where(fn ($query) => $query->whereNull('last_remembered_at')->orWhere('last_remembered_at', '<=', now()->subMonths(6))); } }