fix tables to have school year, and remove school year from other tables.
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 5m48s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 1m33s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 5m48s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 1m33s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
trait HasOptionalSchoolYearContext
|
||||
{
|
||||
public function scopeForOptionalSchoolYearContext(Builder $query, object $context): Builder
|
||||
{
|
||||
return $query->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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user