fix parent pages and teachers and admin
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-07-09 13:56:22 -04:00
parent 21c9322127
commit 02ba2fe6b6
34 changed files with 2306 additions and 99 deletions
+65
View File
@@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class TeacherClass extends BaseModel
{
@@ -162,6 +163,70 @@ class TeacherClass extends BaseModel
->all();
}
/**
* Distinct section identifiers this teacher can access, expanded across legacy
* `classSection.id` PKs and `classSection.class_section_id` business codes.
*
* @return list<int>
*/
public static function distinctAccessibleSectionIdsForTeacher(int $userId): array
{
$sectionIds = static::distinctSectionIdsForTeacher($userId);
if ($sectionIds === []) {
return [];
}
$expanded = [];
if (Schema::hasTable('classSection')) {
$codeRows = DB::table('classSection')
->select('id', 'class_section_id')
->whereIn('class_section_id', $sectionIds)
->get();
$matchedRawIds = [];
foreach ($codeRows as $row) {
$matchedRawIds[(int) $row->class_section_id] = true;
foreach ([(int) $row->id, (int) $row->class_section_id] as $sectionId) {
if ($sectionId > 0) {
$expanded[$sectionId] = true;
}
}
}
$unmatchedSectionIds = array_values(array_filter(
$sectionIds,
static fn (int $sectionId): bool => ! isset($matchedRawIds[$sectionId]),
));
$pkRows = $unmatchedSectionIds === []
? collect()
: DB::table('classSection')
->select('id', 'class_section_id')
->whereIn('id', $unmatchedSectionIds)
->get();
foreach ($pkRows as $row) {
foreach ([(int) $row->id, (int) $row->class_section_id] as $sectionId) {
if ($sectionId > 0) {
$expanded[$sectionId] = true;
}
}
}
}
foreach ($sectionIds as $sectionId) {
if (! isset($expanded[(int) $sectionId])) {
$expanded[(int) $sectionId] = true;
}
}
$ids = array_map('intval', array_keys($expanded));
sort($ids);
return $ids;
}
/** legacy: getClassSectionsByTeacherId() */
public static function getClassSectionsByTeacherId(int $teacherId): array
{