fix tests
This commit is contained in:
@@ -10,9 +10,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StudentDirectoryService
|
||||
{
|
||||
public function __construct(private StudentConfigService $configService)
|
||||
{
|
||||
}
|
||||
public function __construct(private StudentConfigService $configService) {}
|
||||
|
||||
public function assignmentData(?string $schoolYear = null): array
|
||||
{
|
||||
@@ -55,7 +53,7 @@ class StudentDirectoryService
|
||||
$studentId = (int) ($student['id'] ?? 0);
|
||||
$sectionNames = StudentClass::getClassSectionsByStudentIdWithFlags($studentId, $schoolYear, true);
|
||||
$sectionIds = StudentClass::getClassSectionIdsByStudentId($studentId, $schoolYear);
|
||||
$sectionDisplay = !empty($sectionNames) ? implode(', ', $sectionNames) : '';
|
||||
$sectionDisplay = ! empty($sectionNames) ? implode(', ', $sectionNames) : '';
|
||||
|
||||
$parentId = (int) ($student['parent_id'] ?? 0);
|
||||
$emergencyInfo = $parentId > 0
|
||||
@@ -64,7 +62,7 @@ class StudentDirectoryService
|
||||
|
||||
$studentData[] = [
|
||||
'student_id' => $studentId,
|
||||
'name' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
|
||||
'name' => trim(($student['firstname'] ?? '').' '.($student['lastname'] ?? '')),
|
||||
'age' => $student['age'] ?? 'N/A',
|
||||
'email' => $emergencyInfo['email'] ?? '',
|
||||
'phone' => $emergencyInfo['cellphone'] ?? '',
|
||||
@@ -149,9 +147,10 @@ class StudentDirectoryService
|
||||
$names = $classMap[$studentId] ?? [];
|
||||
$names = array_values(array_unique(array_filter($names)));
|
||||
$student['class_sections'] = $names;
|
||||
$student['class_section_name'] = !empty($names) ? implode(', ', $names) : 'No class assigned';
|
||||
$student['class_section_name'] = ! empty($names) ? implode(', ', $names) : 'No class assigned';
|
||||
}
|
||||
unset($student);
|
||||
|
||||
return $students;
|
||||
};
|
||||
|
||||
@@ -188,7 +187,7 @@ class StudentDirectoryService
|
||||
'school_year',
|
||||
])
|
||||
->when($selectedYear !== '', fn ($q) => $q->where('school_year', $selectedYear))
|
||||
->when(!empty($parentIds), fn ($q) => $q->whereIn('parent_id', $parentIds))
|
||||
->when(! empty($parentIds), fn ($q) => $q->whereIn('parent_id', $parentIds))
|
||||
->orderBy('lastname')
|
||||
->orderBy('firstname')
|
||||
->get()
|
||||
|
||||
Reference in New Issue
Block a user