Test Setup Failed
Pull Request — master (#510)
by
unknown
08:32
created
app/Imports/UsersImport.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     public function registerEvents(): array
76 76
     {
77 77
         return [
78
-            BeforeSheet::class => function (BeforeSheet $event) {
78
+            BeforeSheet::class => function(BeforeSheet $event) {
79 79
                 $this->sheetNames[] = $event->getSheet()->getTitle();
80 80
                 $this->worksheet = $event->getSheet();
81 81
                 $this->validateClass();
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                     throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
88 88
                 }
89 89
             },
90
-            BeforeImport::class => function (BeforeImport $event) {
90
+            BeforeImport::class => function(BeforeImport $event) {
91 91
                 $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('C'));
92 92
                 if ($this->highestRow < 3) {
93 93
                     $error = \Illuminate\Validation\ValidationException::withMessages([]);
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
                 $mandatorySubject = Institution_class_subject::getMandetorySubjects($this->file['institution_class_id']);
115 115
                 // dd($mandatorySubject);
116 116
                 $subjects = getMatchingKeys($row);
117
-                $genderId  = null;
117
+                $genderId = null;
118 118
                 switch ($row['gender_mf']) {
119 119
                     case 'M':
120 120
                         $genderId = $row['gender_mf'] = 1;
121 121
                         $this->maleStudentsCount += 1;
122 122
                         break;
123 123
                     case 'F':
124
-                        $genderId =  $row['gender_mf'] = 2;
124
+                        $genderId = $row['gender_mf'] = 2;
125 125
                         $this->femaleStudentsCount += 1;
126 126
                         break;
127 127
                 }
128 128
 
129
-                $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first();
130
-                $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first();
131
-                $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first();
129
+                $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first();
130
+                $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first();
131
+                $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first();
132 132
                 $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first();
133 133
 
134 134
 
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
 
145 145
                 $openemisStudent = $this->uniqueUid::getUniqueAlphanumeric();
146 146
                 \Log::debug('Security_user');
147
-                $student =  Security_user::create([
147
+                $student = Security_user::create([
148 148
                     'username' => str_replace('-', '', $openemisStudent),
149 149
                     'openemis_no' => $openemisStudent,
150 150
                     'first_name' => $row['full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
151 151
                     'last_name' => genNameWithInitials($row['full_name']),
152
-                    'preferred_name' => $row['preferred_name'] ,
152
+                    'preferred_name' => $row['preferred_name'],
153 153
                     'gender_id' => $genderId,
154 154
                     'date_of_birth' => $date,
155 155
                     'address' => $row['address'],
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
                 if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) {
235 235
                     try {
236 236
                         // convert Meeter to CM
237
-                        $hight = $row['bmi_height'] / 100;
237
+                        $hight = $row['bmi_height']/100;
238 238
                         //calculate BMI
239
-                        $bodyMass = ($row['bmi_weight']) / pow($hight, 2);
239
+                        $bodyMass = ($row['bmi_weight'])/pow($hight, 2);
240 240
 
241 241
                         $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first();
242 242
 
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
                             'security_user_id' => $student->student_id,
251 251
                             'created_user_id' => $this->file['security_user_id']
252 252
                         ]);
253
-                    } catch (\Throwable $th) {
254
-                        \Log::error('User_body_mass:' . $th->getMessage());
253
+                    }catch (\Throwable $th) {
254
+                        \Log::error('User_body_mass:'.$th->getMessage());
255 255
                     }
256 256
                 }
257 257
 
258 258
 
259 259
                 if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) {
260 260
 
261
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first();
262
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first();
263
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first();
261
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first();
262
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first();
263
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first();
264 264
                     $openemisFather = $this->uniqueUid::getUniqueAlphanumeric();
265 265
 
266 266
                     $identityType = ($identityType !== null) ? $identityType->id : null;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                             User_contact::createOrUpdate($father, $this->file['security_user_id']);
299 299
                         }
300 300
                         Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
301
-                    } else {
301
+                    }else {
302 302
                         Security_user::where('id', '=', $father->id)
303 303
                             ->update(['is_guardian' => 1]);
304 304
                         $father['guardian_relation_id'] = 1;
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
                 }
312 312
 
313 313
                 if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) {
314
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first();
315
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first();
316
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first();
314
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first();
315
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first();
316
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first();
317 317
                     $openemisMother = $this->uniqueUid::getUniqueAlphanumeric();
318 318
 
319 319
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                             User_contact::createOrUpdate($mother, $this->file['security_user_id']);
350 350
                         }
351 351
                         Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
352
-                    } else {
352
+                    }else {
353 353
                         Security_user::where('id', '=', $mother->id)
354 354
                             ->update(['is_guardian' => 1]);
355 355
                         $mother['guardian_relation_id'] = 2;
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 
365 365
                 if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) {
366 366
                     $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2;
367
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first();
368
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first();
369
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first();
367
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first();
368
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first();
369
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first();
370 370
                     $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric();
371 371
 
372 372
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
                             User_contact::createOrUpdate($guardian, $this->file['security_user_id']);
404 404
                         }
405 405
                         Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
406
-                    } else {
406
+                    }else {
407 407
                         Security_user::where('id', '=', $guardian->id)
408 408
                             ->update(['is_guardian' => 1]);
409 409
                         $guardian['guardian_relation_id'] = 3;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 
436 436
                 if ($totalStudents['total'] > $institutionClass->no_of_students) {
437 437
                     $error = \Illuminate\Validation\ValidationException::withMessages([]);
438
-                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]);
438
+                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]);
439 439
                     $failures = [0 => $failure];
440 440
                     throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
441 441
                     Log::info('email-sent', [$this->file]);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
                         'total_female_students' => $totalStudents['total_female_students']
448 448
                     ]);
449 449
             }
450
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
450
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
451 451
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
452 452
             //            $failure = new Failure(3, 'remark', [3 => ], [null]);
453 453
             $failures = $e->failures();
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
             '*.full_name' => 'required|regex:/^[\pL\s\-]+$/u|max:256',
464 464
             '*.preferred_name' => 'required|regex:/^[\pL\s\-]+$/u|max:90',
465 465
             '*.gender_mf' => 'required|in:M,F',
466
-            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'],
466
+            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'],
467 467
             '*.address' => 'nullable',
468 468
             '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place',
469 469
             '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate',
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
             '*.academic_period' => 'required|exists:academic_periods,name',
474 474
             '*.education_grade' => 'required',
475 475
             '*.option_*' => 'nullable|exists:education_subjects,name',
476
-            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'],
477
-            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'],
476
+            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'],
477
+            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'],
478 478
             '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].'
479 479
             '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name',
480 480
             '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/',
Please login to merge, or discard this patch.