where(function (Builder $q) use ($context) { $q->whereNull($this->getTable().'.school_year') ->orWhere($this->getTable().'.school_year', $context->yearName()); }); } public function scopeOnlyForSchoolYearContext(Builder $query, object $context): Builder { return $query->where($this->getTable().'.school_year', $context->yearName()); } }