Files
alrahma_sunday_school_api/app/Services/School/SemesterSelectionService.php
T
2026-03-11 01:38:20 -04:00

34 lines
843 B
PHP

<?php
namespace App\Services\School;
use App\Models\Configuration;
class SemesterSelectionService
{
public function selectedTeacherSemester(): string
{
$selected = trim((string) (session()->get('teacher_scores_selected_semester') ?? ''));
if ($selected !== '') {
return $this->normalize($selected);
}
$fallback = trim((string) (session()->get('semester') ?? ''));
if ($fallback !== '') {
return $this->normalize($fallback);
}
$configSemester = trim((string) (Configuration::getConfig('semester') ?? ''));
if ($configSemester !== '') {
return $this->normalize($configSemester);
}
return 'Fall';
}
private function normalize(string $value): string
{
return ucfirst(strtolower($value));
}
}