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] [$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)) { if (empty($children)) {
$demoStudent = Database::selectOne("SELECT id FROM students LIMIT 1"); $demoStudents = Database::select("SELECT id FROM students LIMIT 3");
if ($demoStudent) { if (!empty($demoStudents)) {
Database::insert( foreach ($demoStudents as $demoStudent) {
"INSERT IGNORE INTO guardian_students (guardian_id, student_id, relationship_type) VALUES (?, ?, 'father')", Database::insert(
[$guardianId, $demoStudent['id']] "INSERT IGNORE INTO guardian_students (guardian_id, student_id, relationship_type) VALUES (?, ?, 'father')",
); [$guardianId, $demoStudent['id']]
);
}
// Re-fetch // Re-fetch
$children = Database::select( $children = Database::select(
"SELECT s.id, s.uuid, s.full_name, s.national_id, s.grade_level, s.stream "SELECT s.id, s.uuid, s.full_name, s.national_id, s.grade_level, s.stream