archetecture security fix

This commit is contained in:
root
2026-06-11 03:22:12 -04:00
parent 6def9993da
commit 9483750161
3126 changed files with 177194 additions and 37211 deletions
@@ -4,9 +4,12 @@ namespace App\Services\Administrator;
use App\Models\Configuration;
use Carbon\Carbon;
use Illuminate\Support\Facades\Schema;
class AdministratorSharedService
{
protected ?bool $teacherClassHasSemesterColumn = null;
public function __construct(
protected Configuration $configuration
) {
@@ -150,4 +153,13 @@ class AdministratorSharedService
return count(array_unique($ids));
}
public function teacherClassSupportsSemester(): bool
{
if ($this->teacherClassHasSemesterColumn !== null) {
return $this->teacherClassHasSemesterColumn;
}
return $this->teacherClassHasSemesterColumn = Schema::hasColumn('teacher_class', 'semester');
}
}
@@ -143,13 +143,18 @@ class TeacherSubmissionNotificationService
return [];
}
return ClassSection::query()
$query = ClassSection::query()
->select('teacher_class.class_section_id', 'teacher_class.teacher_id')
->join('teacher_class', 'teacher_class.class_section_id', '=', 'classSection.class_section_id')
->whereIn('teacher_class.teacher_id', $teacherIds)
->where('teacher_class.school_year', $schoolYear)
->where('teacher_class.semester', $semester)
->orderBy('teacher_class.class_section_id')
->orderBy('teacher_class.class_section_id');
if ($this->shared->teacherClassSupportsSemester() && $semester !== '') {
$query->where('teacher_class.semester', $semester);
}
return $query
->get()
->map(static fn ($row): array => [
'class_section_id' => (int) $row->class_section_id,
@@ -21,8 +21,9 @@ class TeacherSubmissionReportService
{
$semester = $this->shared->getSemester($filters['semester'] ?? null);
$schoolYear = $this->shared->getSchoolYear($filters['school_year'] ?? null);
$teacherClassSupportsSemester = $this->shared->teacherClassSupportsSemester();
$assignmentRows = DB::table('teacher_class as tc')
$assignmentQuery = DB::table('teacher_class as tc')
->select([
'tc.class_section_id',
'cs.class_section_name',
@@ -34,8 +35,13 @@ class TeacherSubmissionReportService
->leftJoin('classSection as cs', 'cs.class_section_id', '=', 'tc.class_section_id')
->leftJoin('users as u', 'u.id', '=', 'tc.teacher_id')
->where('tc.school_year', $schoolYear)
->where('tc.semester', $semester)
->orderBy('cs.class_section_name')
->orderBy('cs.class_section_name');
if ($teacherClassSupportsSemester && $semester !== '') {
$assignmentQuery->where('tc.semester', $semester);
}
$assignmentRows = $assignmentQuery
->get()
->map(fn ($r) => (array) $r)
->all();