fix: multi-child demo linking in Guardian portal

This commit is contained in:
Hamza-Ayed
2026-08-28 23:18:18 +03:00
parent 8aab91c77f
commit 731194cba0
@@ -25,14 +25,16 @@ class GuardianController
[$guardianId]
);
// If no children linked (for demo purposes, link all students or the first one if empty)
// If no children linked (for demo purposes, link up to 3 students so the multi-child UI can be tested)
if (empty($children)) {
$demoStudent = Database::selectOne("SELECT id FROM students LIMIT 1");
if ($demoStudent) {
Database::insert(
"INSERT IGNORE INTO guardian_students (guardian_id, student_id, relationship_type) VALUES (?, ?, 'father')",
[$guardianId, $demoStudent['id']]
);
$demoStudents = Database::select("SELECT id FROM students LIMIT 3");
if (!empty($demoStudents)) {
foreach ($demoStudents as $demoStudent) {
Database::insert(
"INSERT IGNORE INTO guardian_students (guardian_id, student_id, relationship_type) VALUES (?, ?, 'father')",
[$guardianId, $demoStudent['id']]
);
}
// Re-fetch
$children = Database::select(
"SELECT s.id, s.uuid, s.full_name, s.national_id, s.grade_level, s.stream