belongsTo(Member::class); } public function subscription(): BelongsTo { return $this->belongsTo(Subscription::class); } public function status(): BelongsTo { return $this->belongsTo(Status::class); } public function scopeWhereNeedsPayment(Builder $q): Builder { return $q->whereHas('status', function ($q) { return $q->needsPayment(); }); } public function scopeWhereNeedsBill(Builder $q): Builder { return $q->whereHas('status', function ($q) { return $q->where('is_bill', true); }); } public function scopeWhereNeedsRemember(Builder $q): Builder { 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(3))); } }