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,