fix parent, teacher and admin pages

This commit is contained in:
root
2026-04-25 00:00:23 -04:00
parent 4cd98f1d30
commit eafe4eb134
30 changed files with 1566 additions and 105 deletions
@@ -9,6 +9,10 @@ class TeacherAttendanceFormResource extends JsonResource
{
public function toArray(Request $request): array
{
$enable = (int)($this['enable_attendance'] ?? 0);
$res = $this->resource;
$hasCanEditKey = is_array($res) && array_key_exists('can_edit', $res);
return [
'teacher_name' => $this['teacher_name'] ?? null,
'students' => $this['students'] ?? [],
@@ -17,7 +21,8 @@ class TeacherAttendanceFormResource extends JsonResource
'sunday_dates' => $this['sunday_dates'] ?? [],
'current_sunday' => $this['current_sunday'] ?? null,
'enable_attendance' => $this['enable_attendance'] ?? null,
'can_edit' => (bool)($this['can_edit'] ?? false),
// Do not default missing `can_edit` to false — that disables the whole form while attendance is enabled.
'can_edit' => $hasCanEditKey ? (bool) $this['can_edit'] : ($enable === 1),
'class_id' => $this['class_id'] ?? null,
'no_school_days' => $this['no_school_days'] ?? [],
'today' => $this['today'] ?? null,
@@ -9,9 +9,15 @@ class FrontendUserResource extends JsonResource
{
public function toArray(Request $request): array
{
$teacherContext = method_exists($this->resource, 'teacherSessionContext')
? $this->resource->teacherSessionContext()
: ['class_section_id' => null, 'class_section_name' => null];
return [
'firstname' => $this->firstname ?? null,
'lastname' => $this->lastname ?? null,
'class_section_id' => $teacherContext['class_section_id'],
'class_section_name' => $teacherContext['class_section_name'],
];
}
}
@@ -13,6 +13,7 @@ class SchoolCalendarEventResource extends JsonResource
'title' => (string) ($this['title'] ?? ''),
'start' => (string) ($this['start'] ?? ''),
'description' => (string) ($this['description'] ?? ''),
'backgroundColor' => $this['backgroundColor'] ?? null,
'extendedProps' => (array) ($this['extendedProps'] ?? []),
];
}