add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
@@ -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);
}
}