Test Setup Failed
Pull Request — master (#503)
by
unknown
10:40
created
app/Imports/UsersImport.php 1 patch
Spacing   +29 added lines, -29 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,7 +114,7 @@  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;
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
                         $this->maleStudentsCount += 1;
123 123
                         break;
124 124
                     case 'F':
125
-                        $genderId =  $row['gender_mf'] = 2;
125
+                        $genderId = $row['gender_mf'] = 2;
126 126
                         $genderId = 2;
127 127
                         $this->femaleStudentsCount += 1;
128 128
                         break;
129 129
                 }
130 130
 
131
-                $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first();
132
-                $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first();
133
-                $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first();
131
+                $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first();
132
+                $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first();
133
+                $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first();
134 134
                 $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first();
135 135
 
136 136
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
                 $openemisStudent = $this->uniqueUid::getUniqueAlphanumeric();
148 148
                 \Log::debug('Security_user');
149
-                $student =  Security_user::create([
149
+                $student = Security_user::create([
150 150
                     'username' => str_replace('-', '', $openemisStudent),
151 151
                     'openemis_no' => $openemisStudent,
152 152
                     'first_name' => $row['full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
                 if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) {
236 236
                     try {
237 237
                         // convert Meeter to CM
238
-                        $hight = $row['bmi_height'] / 100;
238
+                        $hight = $row['bmi_height']/100;
239 239
                         //calculate BMI
240
-                        $bodyMass = ($row['bmi_weight']) / pow($hight, 2);
240
+                        $bodyMass = ($row['bmi_weight'])/pow($hight, 2);
241 241
 
242 242
                         $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first();
243 243
 
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
                             'security_user_id' => $student->student_id,
252 252
                             'created_user_id' => $this->file['security_user_id']
253 253
                         ]);
254
-                    } catch (\Throwable $th) {
255
-                        \Log::error('User_body_mass:' . $th->getMessage());
254
+                    }catch (\Throwable $th) {
255
+                        \Log::error('User_body_mass:'.$th->getMessage());
256 256
                     }
257 257
                 }
258 258
 
259 259
 
260 260
                 if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) {
261 261
 
262
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first();
263
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first();
264
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first();
262
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first();
263
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first();
264
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first();
265 265
                     $openemisFather = $this->uniqueUid::getUniqueAlphanumeric();
266 266
 
267 267
                     $identityType = ($identityType !== null) ? $identityType->id : null;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                             User_contact::createOrUpdate($father, $this->file['security_user_id']);
300 300
                         }
301 301
                         Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
302
-                    } else {
302
+                    }else {
303 303
                         Security_user::where('id', '=', $father->id)
304 304
                             ->update(['is_guardian' => 1]);
305 305
                         $father['guardian_relation_id'] = 1;
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
                 }
313 313
 
314 314
                 if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) {
315
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first();
316
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first();
317
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first();
315
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first();
316
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first();
317
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first();
318 318
                     $openemisMother = $this->uniqueUid::getUniqueAlphanumeric();
319 319
 
320 320
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
                             User_contact::createOrUpdate($mother, $this->file['security_user_id']);
351 351
                         }
352 352
                         Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
353
-                    } else {
353
+                    }else {
354 354
                         Security_user::where('id', '=', $mother->id)
355 355
                             ->update(['is_guardian' => 1]);
356 356
                         $mother['guardian_relation_id'] = 2;
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 
366 366
                 if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) {
367 367
                     $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2;
368
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first();
369
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first();
370
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first();
368
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first();
369
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first();
370
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first();
371 371
                     $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric();
372 372
 
373 373
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                             User_contact::createOrUpdate($guardian, $this->file['security_user_id']);
405 405
                         }
406 406
                         Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
407
-                    } else {
407
+                    }else {
408 408
                         Security_user::where('id', '=', $guardian->id)
409 409
                             ->update(['is_guardian' => 1]);
410 410
                         $guardian['guardian_relation_id'] = 3;
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 
437 437
                 if ($totalStudents['total'] > $institutionClass->no_of_students) {
438 438
                     $error = \Illuminate\Validation\ValidationException::withMessages([]);
439
-                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]);
439
+                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]);
440 440
                     $failures = [0 => $failure];
441 441
                     throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
442 442
                     Log::info('email-sent', [$this->file]);
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
                         'total_female_students' => $totalStudents['total_female_students']
449 449
                     ]);
450 450
             }
451
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
451
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
452 452
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
453 453
             //            $failure = new Failure(3, 'remark', [3 => ], [null]);
454 454
             $failures = $e->failures();
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         return [
464 464
             '*.full_name' => 'required|regex:/^[\pL\s\-]+$/u|max:100',
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.