update policy and fix other issues
This commit is contained in:
@@ -1200,7 +1200,10 @@ class InventoryController extends BaseController
|
||||
->where('ur.user_id', $user_id)
|
||||
->get()->getResultArray();
|
||||
|
||||
$roleNames = array_map(fn($r) => $r['name'], $roles);
|
||||
$roleNames = array_map(
|
||||
static fn($r): string => strtolower(trim((string) ($r['name'] ?? ''))),
|
||||
$roles
|
||||
);
|
||||
|
||||
if (in_array('teacher', $roleNames, true)) {
|
||||
$user['role_name'] = 'teacher';
|
||||
@@ -1211,12 +1214,15 @@ class InventoryController extends BaseController
|
||||
}
|
||||
|
||||
// 4) Collect class_section IDs
|
||||
$classSectionIds = array_column($classes, 'class_section_id');
|
||||
$classSectionIds = array_values(array_filter(array_map(
|
||||
static fn($class): int => (int) ($class['class_section_id'] ?? 0),
|
||||
$classes
|
||||
)));
|
||||
$studentsData = [];
|
||||
|
||||
// 5) Group students by class_section_id
|
||||
if (!empty($classSectionIds)) {
|
||||
$students = $this->studentClassModel->getStudentsByClassSectionIds($classSectionIds);
|
||||
$students = $this->studentClassModel->getStudentsByClassSectionIds($classSectionIds, $this->schoolYear);
|
||||
foreach ($students as $student) {
|
||||
$studentsData[$student['class_section_id']][] = $student;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user