This commit is contained in:
@@ -77,6 +77,13 @@ class ConfigurationModel extends Model
|
||||
public function getConfig($key)
|
||||
{
|
||||
$key = (string) $key;
|
||||
if ($key === 'school_year') {
|
||||
$activeSchoolYear = $this->activeSchoolYearName();
|
||||
if ($activeSchoolYear !== null) {
|
||||
return $activeSchoolYear;
|
||||
}
|
||||
}
|
||||
|
||||
if ($key === 'semester') {
|
||||
try {
|
||||
$semester = (new \App\Services\SemesterRangeService($this))->getSemesterForDate();
|
||||
@@ -90,4 +97,26 @@ class ConfigurationModel extends Model
|
||||
|
||||
return $this->getConfigValueByKey($key);
|
||||
}
|
||||
|
||||
private function activeSchoolYearName(): ?string
|
||||
{
|
||||
try {
|
||||
if (! $this->db->tableExists('school_years')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = $this->db->table('school_years')
|
||||
->select('name')
|
||||
->where('status', 'active')
|
||||
->orderBy('id', 'DESC')
|
||||
->get(1)
|
||||
->getRowArray();
|
||||
|
||||
$name = trim((string) ($row['name'] ?? ''));
|
||||
|
||||
return $name !== '' ? $name : null;
|
||||
} catch (\Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user