Files
alrahma_sunday_school_api/app/Services/Assignment/AssignmentSectionService.php
T
2026-06-11 11:46:12 -04:00

29 lines
726 B
PHP

<?php
namespace App\Services\Assignment;
use App\Models\ClassSection;
class AssignmentSectionService
{
public function __construct(private ClassSection $classSection) {}
public function getSectionNamesMap(array $sectionIds): array
{
if (empty($sectionIds)) {
return [];
}
return $this->classSection
->newQuery()
->whereIn('class_section_id', $sectionIds)
->get()
->mapWithKeys(function ($section) {
$name = $section->class_section_name ?? $section->section_name ?? $section->name ?? '';
return [(int) $section->class_section_id => (string) $name];
})
->all();
}
}