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

This commit is contained in:
root
2026-07-06 22:27:21 -04:00
parent 304fa6bfd0
commit 58726ee0e9
13 changed files with 1343 additions and 120 deletions
-5
View File
@@ -12,7 +12,6 @@ use FPDF;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class BadgeService
{
@@ -237,10 +236,6 @@ class BadgeService
$query->whereIn('users.id', $selectedUserIds);
}
if (! empty($schoolYear) && Schema::hasColumn('user_roles', 'school_year')) {
$query->where('user_roles.school_year', $schoolYear);
}
return array_map(static fn ($row) => (array) $row, $query->get()->all());
}
@@ -42,17 +42,17 @@ class BadgeStudentLookupService
'students.lastname',
'students.registration_grade',
'students.school_id',
'students.school_year',
DB::raw('COALESCE(MAX(sc.school_year), ?) as school_year'),
DB::raw($classSectionAggregate),
])
->addBinding((string) ($schoolYear ?? ''), 'select')
->where('students.is_active', 1)
->groupBy(
'students.id',
'students.firstname',
'students.lastname',
'students.registration_grade',
'students.school_id',
'students.school_year'
'students.school_id'
)
->orderBy('students.lastname')
->orderBy('students.firstname');
@@ -60,10 +60,7 @@ class BadgeStudentLookupService
if (! empty($selectedStudentIds)) {
$query->whereIn('students.id', $selectedStudentIds);
} elseif (! empty($schoolYear)) {
$query->where(function ($q) use ($schoolYear) {
$q->where('students.school_year', $schoolYear)
->orWhereNotNull('sc.student_id');
});
$query->whereNotNull('sc.student_id');
}
$rows = array_map(static fn ($row) => (array) $row, $query->get()->all());
@@ -206,22 +206,6 @@ class BadgeUserLookupService
} catch (\Throwable) {
}
if (empty($schoolYears)) {
try {
if (Schema::hasTable('user_roles') && Schema::hasColumn('user_roles', 'school_year')) {
$schoolYears = DB::table('user_roles')
->selectRaw('DISTINCT school_year')
->whereNotNull('school_year')
->orderByDesc('school_year')
->pluck('school_year')
->filter()
->values()
->all();
}
} catch (\Throwable) {
}
}
return $schoolYears;
}
@@ -4,6 +4,7 @@ namespace App\Services\SchoolYears;
use App\Models\Configuration;
use App\Models\SchoolYear;
use App\Support\SchoolYear\SchoolYearTableRegistry;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
@@ -143,15 +144,17 @@ class SchoolYearContextService
private function legacySchoolYearNames(): array
{
$tables = [
'students', 'parents', 'users', 'staff', 'student_class', 'teacher_class',
'events', 'calendar_events', 'scan_log', 'exam_drafts', 'inventory_items',
'inventory_movements', 'certificate_records', 'semester_scores', 'final_scores',
'student_class', 'teacher_class',
'events', 'calendar_events', 'exam_drafts',
'certificate_records', 'semester_scores', 'final_score',
'student_decisions', 'below_sixty_decisions', 'whatsapp_group_links',
];
$names = [];
foreach ($tables as $table) {
if (! Schema::hasTable($table) || ! Schema::hasColumn($table, 'school_year')) {
if (! SchoolYearTableRegistry::isYearScoped($table)
|| ! Schema::hasTable($table)
|| ! Schema::hasColumn($table, 'school_year')) {
continue;
}