fix gitlab tests

This commit is contained in:
root
2026-06-09 02:32:58 -04:00
parent 20a0b6c4e5
commit 6def9993da
1489 changed files with 10449 additions and 11356 deletions
+10 -11
View File
@@ -67,7 +67,7 @@ class FamilyMutationService
}
$familyId = $this->familyIdFromStudentPrimary($studentId);
if (! $familyId) {
if (!$familyId) {
return ['ok' => false, 'message' => 'No primary family found for this student'];
}
@@ -83,13 +83,13 @@ class FamilyMutationService
}
$familyId = $this->familyIdFromStudentPrimary($studentId);
if (! $familyId) {
if (!$familyId) {
return ['ok' => false, 'message' => 'No primary family found for this student'];
}
return DB::transaction(function () use ($email, $firstname, $lastname, $relation, $familyId) {
$user = User::query()->where('email', $email)->first();
if (! $user) {
if (!$user) {
$user = User::query()->create([
'firstname' => (string) ($firstname ?? ''),
'lastname' => (string) ($lastname ?? ''),
@@ -167,7 +167,7 @@ class FamilyMutationService
{
$legacyTable = 'parents';
$this->ensureTablesExist(['families', 'family_students', 'family_guardians']);
if (! Schema::hasTable($legacyTable)) {
if (!Schema::hasTable($legacyTable)) {
return ['ok' => false, 'message' => "Legacy table '{$legacyTable}' not found"];
}
@@ -192,7 +192,6 @@ class FamilyMutationService
if ($firstId <= 0 || ($secondId <= 0 && $email === '')) {
$skipped++;
continue;
}
@@ -204,7 +203,7 @@ class FamilyMutationService
$userId = $secondId;
} else {
$user = User::query()->where('email', $email)->first();
if (! $user) {
if (!$user) {
$user = User::query()->create([
'firstname' => (string) ($r['firstname'] ?? ''),
'lastname' => (string) ($r['lastname'] ?? ''),
@@ -252,7 +251,7 @@ class FamilyMutationService
private function ensureFamilyForPrimaryParent(int $primaryUserId, int &$createdCounter): int
{
$code = 'FAM-'.$primaryUserId;
$code = 'FAM-' . $primaryUserId;
$row = Family::query()->where('family_code', $code)->first();
if ($row) {
return (int) $row->id;
@@ -260,7 +259,7 @@ class FamilyMutationService
$family = Family::query()->create([
'family_code' => $code,
'household_name' => 'Family of User '.$primaryUserId,
'household_name' => 'Family of User ' . $primaryUserId,
'is_active' => 1,
]);
$createdCounter++;
@@ -310,11 +309,11 @@ class FamilyMutationService
private function familyIdFromStudentPrimary(int $studentId): ?int
{
$student = Student::query()->select('parent_id')->find($studentId);
if (! $student || empty($student->parent_id)) {
if (!$student || empty($student->parent_id)) {
return null;
}
$code = 'FAM-'.(int) $student->parent_id;
$code = 'FAM-' . (int) $student->parent_id;
$row = Family::query()->select('id')->where('family_code', $code)->first();
if ($row) {
return (int) $row->id;
@@ -332,7 +331,7 @@ class FamilyMutationService
private function ensureTablesExist(array $tables): void
{
foreach ($tables as $table) {
if (! Schema::hasTable($table)) {
if (!Schema::hasTable($table)) {
Log::warning('Family tables missing', ['table' => $table]);
throw new \RuntimeException("Missing required table '{$table}'. Run migrations.");
}
@@ -6,7 +6,9 @@ use App\Services\Email\EmailDispatchService;
class FamilyNotificationService
{
public function __construct(private EmailDispatchService $dispatch) {}
public function __construct(private EmailDispatchService $dispatch)
{
}
public function sendComposeEmail(
string $recipient,
+13 -10
View File
@@ -5,11 +5,14 @@ namespace App\Services\Families;
use App\Models\Family;
use App\Models\Student;
use App\Models\StudentClass;
use App\Models\User;
use Illuminate\Support\Facades\DB;
class FamilyQueryService
{
public function __construct(private FamilyFinanceService $finance) {}
public function __construct(private FamilyFinanceService $finance)
{
}
public function listStudentsForSelect(): array
{
@@ -29,7 +32,7 @@ class FamilyQueryService
return [];
}
$qs = '%'.str_replace(['%', '_'], ['\\%', '\\_'], $query).'%';
$qs = '%' . str_replace(['%', '_'], ['\\%', '\\_'], $query) . '%';
$students = DB::table('students')
->select('id', 'firstname', 'lastname')
@@ -60,7 +63,7 @@ class FamilyQueryService
$items[] = [
'type' => 'student',
'id' => (int) ($s['id'] ?? 0),
'label' => trim(($s['firstname'] ?? '').' '.($s['lastname'] ?? '')),
'label' => trim(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? '')),
'sub' => 'Student',
];
}
@@ -68,8 +71,8 @@ class FamilyQueryService
$items[] = [
'type' => 'guardian',
'id' => (int) ($g['id'] ?? 0),
'label' => trim(($g['firstname'] ?? '').' '.($g['lastname'] ?? '')),
'sub' => trim(($g['email'] ?? '').' '.($g['cellphone'] ?? '')),
'label' => trim(($g['firstname'] ?? '') . ' ' . ($g['lastname'] ?? '')),
'sub' => trim(($g['email'] ?? '') . ' ' . ($g['cellphone'] ?? '')),
];
}
@@ -90,7 +93,7 @@ class FamilyQueryService
->orderBy('s.firstname')
->select('s.id as student_id')
->first();
if ($row && ! empty($row->student_id)) {
if ($row && !empty($row->student_id)) {
return (int) $row->student_id;
}
@@ -233,7 +236,7 @@ class FamilyQueryService
unset($fam);
$data['families'] = $families;
if (! empty($families)) {
if (!empty($families)) {
$familyId = (int) ($families[0]['id'] ?? 0);
$data['guardians'] = $familyId ? $this->listGuardiansByFamily($familyId) : [];
}
@@ -303,7 +306,7 @@ class FamilyQueryService
)
->find($familyId);
if (! $family) {
if (!$family) {
return null;
}
@@ -361,7 +364,7 @@ class FamilyQueryService
foreach ($guardians as $g) {
$gid = (int) ($g['user_id'] ?? 0);
if ($gid > 0) {
$guardianMap[$gid] = trim(($g['firstname'] ?? '').' '.($g['lastname'] ?? ''));
$guardianMap[$gid] = trim(($g['firstname'] ?? '') . ' ' . ($g['lastname'] ?? ''));
}
}
@@ -375,7 +378,7 @@ class FamilyQueryService
foreach ($rows as &$row) {
$pid = (int) ($row['parent_id'] ?? 0);
$row['parent_label'] = $guardianMap[$pid] ?? ('Parent #'.$pid);
$row['parent_label'] = $guardianMap[$pid] ?? ('Parent #' . $pid);
}
unset($row);