Fix Laravel Pint formatting
This commit is contained in:
@@ -11,9 +11,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class StudentAssignmentService
|
||||
{
|
||||
public function __construct(private StudentConfigService $configService)
|
||||
{
|
||||
}
|
||||
public function __construct(private StudentConfigService $configService) {}
|
||||
|
||||
public function assignClasses(int $studentId, array $classSectionIds, bool $isEventOnly, ?int $userId = null): array
|
||||
{
|
||||
@@ -27,7 +25,7 @@ class StudentAssignmentService
|
||||
}
|
||||
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return ['ok' => false, 'message' => 'Student not found.'];
|
||||
}
|
||||
|
||||
@@ -47,7 +45,7 @@ class StudentAssignmentService
|
||||
}
|
||||
|
||||
$missing = array_diff($classSectionIds, array_keys($sectionMap));
|
||||
if (!empty($missing)) {
|
||||
if (! empty($missing)) {
|
||||
return ['ok' => false, 'message' => 'One or more selected classes do not exist.'];
|
||||
}
|
||||
|
||||
@@ -105,7 +103,7 @@ class StudentAssignmentService
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isEventOnly) {
|
||||
if (! $isEventOnly) {
|
||||
$enrollment = Enrollment::query()
|
||||
->where('student_id', $studentId)
|
||||
->where('school_year', $schoolYear)
|
||||
@@ -143,12 +141,12 @@ class StudentAssignmentService
|
||||
$displayNames = [];
|
||||
foreach ($classSectionIds as $classSectionId) {
|
||||
$section = $sectionMap[$classSectionId] ?? null;
|
||||
if (!$section) {
|
||||
if (! $section) {
|
||||
continue;
|
||||
}
|
||||
$name = (string) ($section['class_section_name'] ?? '');
|
||||
if ($name === '') {
|
||||
$name = 'Section #' . $classSectionId;
|
||||
$name = 'Section #'.$classSectionId;
|
||||
}
|
||||
$displayNames[] = $name;
|
||||
}
|
||||
@@ -180,7 +178,7 @@ class StudentAssignmentService
|
||||
->where('school_year', $schoolYear)
|
||||
->first();
|
||||
|
||||
if (!$row) {
|
||||
if (! $row) {
|
||||
return ['ok' => false, 'message' => 'Assignment not found for this student/class.'];
|
||||
}
|
||||
|
||||
@@ -212,7 +210,7 @@ class StudentAssignmentService
|
||||
->first();
|
||||
|
||||
if ($enrollment) {
|
||||
$newClassId = !empty($remainingIds) ? $remainingIds[0] : null;
|
||||
$newClassId = ! empty($remainingIds) ? $remainingIds[0] : null;
|
||||
if ((int) $enrollment->class_section_id === $classSectionId || $newClassId !== null) {
|
||||
$enrollment->update([
|
||||
'class_section_id' => $newClassId,
|
||||
@@ -298,7 +296,7 @@ class StudentAssignmentService
|
||||
$payload['updated_by'] = $modifiedBy;
|
||||
}
|
||||
|
||||
$results[$table . '_updated'] = DB::table($table)
|
||||
$results[$table.'_updated'] = DB::table($table)
|
||||
->where('student_id', $studentId)
|
||||
->where('semester', $semester)
|
||||
->where('school_year', $schoolYear)
|
||||
@@ -312,6 +310,7 @@ class StudentAssignmentService
|
||||
{
|
||||
$values = array_map('intval', $ids);
|
||||
$values = array_values(array_unique(array_filter($values, static fn ($v) => $v > 0)));
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StudentAutoDistributionService
|
||||
{
|
||||
public function __construct(private StudentConfigService $configService)
|
||||
{
|
||||
}
|
||||
public function __construct(private StudentConfigService $configService) {}
|
||||
|
||||
public function promotionTotals(?string $schoolYear = null): array
|
||||
{
|
||||
@@ -30,6 +28,7 @@ class StudentAutoDistributionService
|
||||
$name = strtolower($nameRaw);
|
||||
if ($name === 'kg' || $name === 'youth') {
|
||||
$wanted[] = $row;
|
||||
|
||||
continue;
|
||||
}
|
||||
if (ctype_digit($name)) {
|
||||
@@ -167,6 +166,7 @@ class StudentAutoDistributionService
|
||||
$bestIdx = $idx;
|
||||
}
|
||||
}
|
||||
|
||||
return $bestIdx;
|
||||
};
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -12,7 +12,7 @@ class StudentProfileService
|
||||
public function updateStudent(int $studentId, array $payload): array
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return ['ok' => false, 'message' => 'Student not found.'];
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class StudentProfileService
|
||||
$shouldSyncAllergies = array_key_exists('allergies', $payload);
|
||||
|
||||
DB::transaction(function () use ($student, $studentData, $conditions, $allergies): void {
|
||||
if (!empty($studentData)) {
|
||||
if (! empty($studentData)) {
|
||||
$student->update($studentData);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class StudentProfileService
|
||||
|
||||
private function syncHealthList(int $studentId, string $modelClass, string $field, array $newValues): void
|
||||
{
|
||||
$model = new $modelClass();
|
||||
$model = new $modelClass;
|
||||
$rows = $model->newQuery()->where('student_id', $studentId)->get(['id', $field])->toArray();
|
||||
|
||||
$current = [];
|
||||
@@ -111,14 +111,14 @@ class StudentProfileService
|
||||
$toDeleteKeys = array_diff(array_keys($current), array_keys($incoming));
|
||||
$toInsertKeys = array_diff(array_keys($incoming), array_keys($current));
|
||||
|
||||
if (!empty($toDeleteKeys)) {
|
||||
if (! empty($toDeleteKeys)) {
|
||||
$ids = array_map(fn ($key) => $byId[$key], $toDeleteKeys);
|
||||
if (!empty($ids)) {
|
||||
if (! empty($ids)) {
|
||||
$model->newQuery()->whereIn('id', $ids)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($toInsertKeys)) {
|
||||
if (! empty($toInsertKeys)) {
|
||||
$batch = [];
|
||||
foreach ($toInsertKeys as $key) {
|
||||
$batch[] = [
|
||||
@@ -126,7 +126,7 @@ class StudentProfileService
|
||||
$field => $incoming[$key],
|
||||
];
|
||||
}
|
||||
if (!empty($batch)) {
|
||||
if (! empty($batch)) {
|
||||
$model->newQuery()->insert($batch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ class StudentScoreCardService
|
||||
->where('id', $studentId)
|
||||
->first();
|
||||
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return ['ok' => false, 'message' => 'Student not found.'];
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ class StudentScoreCardService
|
||||
if ($ay !== $by) {
|
||||
return strcmp($by, $ay);
|
||||
}
|
||||
|
||||
return strcmp((string) ($a['semester'] ?? ''), (string) ($b['semester'] ?? ''));
|
||||
});
|
||||
|
||||
@@ -184,7 +185,7 @@ class StudentScoreCardService
|
||||
foreach ($rows as $row) {
|
||||
$year = (string) ($row['school_year'] ?? '');
|
||||
$score = $row['semester_score'] ?? null;
|
||||
if ($year === '' || !is_numeric($score)) {
|
||||
if ($year === '' || ! is_numeric($score)) {
|
||||
continue;
|
||||
}
|
||||
$yearScoreMap[$year][] = (float) $score;
|
||||
@@ -224,14 +225,14 @@ class StudentScoreCardService
|
||||
if ($commentVal === '') {
|
||||
continue;
|
||||
}
|
||||
$key = $year . '|' . $semester;
|
||||
$key = $year.'|'.$semester;
|
||||
$commentMap[$key][$type] = $commentVal;
|
||||
}
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$year = (string) ($row['school_year'] ?? '');
|
||||
$semester = strtolower(trim((string) ($row['semester'] ?? '')));
|
||||
$row['comments'] = $commentMap[$year . '|' . $semester] ?? [];
|
||||
$row['comments'] = $commentMap[$year.'|'.$semester] ?? [];
|
||||
$row['year_score'] = $yearAvg[$year] ?? null;
|
||||
}
|
||||
unset($row);
|
||||
|
||||
@@ -8,9 +8,7 @@ use App\Models\StudentClass;
|
||||
|
||||
class StudentStatusService
|
||||
{
|
||||
public function __construct(private StudentConfigService $configService)
|
||||
{
|
||||
}
|
||||
public function __construct(private StudentConfigService $configService) {}
|
||||
|
||||
public function setActive(int $studentId, bool $isActive, ?int $userId = null): array
|
||||
{
|
||||
@@ -19,7 +17,7 @@ class StudentStatusService
|
||||
$schoolYear = (string) ($context['school_year'] ?? '');
|
||||
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return ['ok' => false, 'message' => 'Student not found.'];
|
||||
}
|
||||
|
||||
@@ -36,7 +34,7 @@ class StudentStatusService
|
||||
->when($schoolYear !== '', fn ($q) => $q->where('school_year', $schoolYear))
|
||||
->first();
|
||||
|
||||
if (!$hasCurrentClass) {
|
||||
if (! $hasCurrentClass) {
|
||||
$lastClass = StudentClass::query()
|
||||
->where('student_id', $studentId)
|
||||
->orderByDesc('updated_at')
|
||||
@@ -59,7 +57,7 @@ class StudentStatusService
|
||||
|
||||
$classLabel = ClassSection::getClassSectionNameBySectionId($restoreClassId);
|
||||
if ($classLabel) {
|
||||
$message .= ' Class assignment restored to ' . $classLabel . '.';
|
||||
$message .= ' Class assignment restored to '.$classLabel.'.';
|
||||
}
|
||||
} else {
|
||||
$message .= ' No class assignment found for the current term.';
|
||||
|
||||
Reference in New Issue
Block a user