This commit is contained in:
@@ -341,8 +341,17 @@ class StudentModel extends Model
|
||||
return array_column($results, 'id');
|
||||
}
|
||||
|
||||
public function getStudentsWithClassAndEnrollment()
|
||||
public function getStudentsWithClassAndEnrollment(?string $schoolYear = null)
|
||||
{
|
||||
$schoolYear = trim((string) $schoolYear);
|
||||
$studentClassJoin = 'student_class.student_id = students.id';
|
||||
$enrollmentJoin = 'enrollments.student_id = students.id';
|
||||
|
||||
if ($schoolYear !== '') {
|
||||
$studentClassJoin .= ' AND student_class.school_year = ' . $this->db->escape($schoolYear);
|
||||
$enrollmentJoin .= ' AND enrollments.school_year = ' . $this->db->escape($schoolYear);
|
||||
}
|
||||
|
||||
return $this->select('
|
||||
students.*,
|
||||
student_class.class_section_id,
|
||||
@@ -351,8 +360,8 @@ class StudentModel extends Model
|
||||
u.firstname AS parent_firstname,
|
||||
u.lastname AS parent_lastname
|
||||
')
|
||||
->join('student_class', 'student_class.student_id = students.id', 'left')
|
||||
->join('enrollments', 'enrollments.student_id = students.id', 'left')
|
||||
->join('student_class', $studentClassJoin, 'left')
|
||||
->join('enrollments', $enrollmentJoin, 'left')
|
||||
->join('users u', 'u.id = students.parent_id', 'left')
|
||||
// keep your original grouping as-is so behavior doesn't change
|
||||
->groupBy('students.id, student_class.class_section_id, enrollments.enrollment_status, enrollments.admission_status')
|
||||
|
||||
Reference in New Issue
Block a user