fix unit tests as well as missing code
API CI/CD / Validate (composer + pint) (push) Successful in 2m7s
API CI/CD / Test (PHPUnit) (push) Failing after 2m23s
API CI/CD / Build frontend assets (push) Successful in 2m18s
API CI/CD / Security audit (push) Successful in 31s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 2m7s
API CI/CD / Test (PHPUnit) (push) Failing after 2m23s
API CI/CD / Build frontend assets (push) Successful in 2m18s
API CI/CD / Security audit (push) Successful in 31s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -222,6 +222,17 @@ class ParentRegistrationService
|
||||
->where('parent_id', $parentId)
|
||||
->firstOrFail();
|
||||
|
||||
$hasEnrollment = \Illuminate\Support\Facades\DB::table('enrollments')
|
||||
->where('student_id', $studentId)
|
||||
->exists();
|
||||
$hasClassAssignment = \Illuminate\Support\Facades\DB::table('student_class')
|
||||
->where('student_id', $studentId)
|
||||
->exists();
|
||||
|
||||
if ($hasEnrollment || $hasClassAssignment) {
|
||||
throw new \RuntimeException('Student deletion is not allowed after enrollment or class assignment.');
|
||||
}
|
||||
|
||||
$student->delete();
|
||||
|
||||
$remaining = Student::query()->where('parent_id', $parentId)->count();
|
||||
|
||||
Reference in New Issue
Block a user