Test Setup Failed
Pull Request — master (#512)
by
unknown
18:18 queued 09:50
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,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,12 +146,12 @@  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.
153 153
                     'last_name' => genNameWithInitials($row['full_name']),
154
-                    'preferred_name' => $row['preferred_name'] ,
154
+                    'preferred_name' => $row['preferred_name'],
155 155
                     'gender_id' => $genderId,
156 156
                     'date_of_birth' => $date,
157 157
                     'address' => $row['address'],
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
                 if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) {
237 237
                     try {
238 238
                         // convert Meeter to CM
239
-                        $hight = $row['bmi_height'] / 100;
239
+                        $hight = $row['bmi_height']/100;
240 240
                         //calculate BMI
241
-                        $bodyMass = ($row['bmi_weight']) / pow($hight, 2);
241
+                        $bodyMass = ($row['bmi_weight'])/pow($hight, 2);
242 242
 
243 243
                         $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first();
244 244
 
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
                             'security_user_id' => $student->student_id,
253 253
                             'created_user_id' => $this->file['security_user_id']
254 254
                         ]);
255
-                    } catch (\Throwable $th) {
256
-                        \Log::error('User_body_mass:' . $th->getMessage());
255
+                    }catch (\Throwable $th) {
256
+                        \Log::error('User_body_mass:'.$th->getMessage());
257 257
                     }
258 258
                 }
259 259
 
260 260
 
261 261
                 if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) {
262 262
 
263
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first();
264
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first();
265
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first();
263
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first();
264
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first();
265
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first();
266 266
                     $openemisFather = $this->uniqueUid::getUniqueAlphanumeric();
267 267
 
268 268
                     $identityType = ($identityType !== null) ? $identityType->id : null;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                             User_contact::createOrUpdate($father, $this->file['security_user_id']);
301 301
                         }
302 302
                         Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
303
-                    } else {
303
+                    }else {
304 304
                         Security_user::where('id', '=', $father->id)
305 305
                             ->update(['is_guardian' => 1]);
306 306
                         $father['guardian_relation_id'] = 1;
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
                 }
314 314
 
315 315
                 if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) {
316
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first();
317
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first();
318
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first();
316
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first();
317
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first();
318
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first();
319 319
                     $openemisMother = $this->uniqueUid::getUniqueAlphanumeric();
320 320
 
321 321
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
                             User_contact::createOrUpdate($mother, $this->file['security_user_id']);
352 352
                         }
353 353
                         Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
354
-                    } else {
354
+                    }else {
355 355
                         Security_user::where('id', '=', $mother->id)
356 356
                             ->update(['is_guardian' => 1]);
357 357
                         $mother['guardian_relation_id'] = 2;
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 
367 367
                 if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) {
368 368
                     $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2;
369
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first();
370
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first();
371
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first();
369
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first();
370
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first();
371
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first();
372 372
                     $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric();
373 373
 
374 374
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                             User_contact::createOrUpdate($guardian, $this->file['security_user_id']);
406 406
                         }
407 407
                         Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
408
-                    } else {
408
+                    }else {
409 409
                         Security_user::where('id', '=', $guardian->id)
410 410
                             ->update(['is_guardian' => 1]);
411 411
                         $guardian['guardian_relation_id'] = 3;
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 
438 438
                 if ($totalStudents['total'] > $institutionClass->no_of_students) {
439 439
                     $error = \Illuminate\Validation\ValidationException::withMessages([]);
440
-                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]);
440
+                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]);
441 441
                     $failures = [0 => $failure];
442 442
                     throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
443 443
                     Log::info('email-sent', [$this->file]);
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
                         'total_female_students' => $totalStudents['total_female_students']
450 450
                     ]);
451 451
             }
452
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
452
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
453 453
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
454 454
             //            $failure = new Failure(3, 'remark', [3 => ], [null]);
455 455
             $failures = $e->failures();
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             '*.full_name' => 'required|regex:/^[\pL\s\-]+$/u|max:256',
466 466
             '*.preferred_name' => 'required|regex:/^[\pL\s\-]+$/u|max:90',
467 467
             '*.gender_mf' => 'required|in:M,F',
468
-            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'],
468
+            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'],
469 469
             '*.address' => 'nullable',
470 470
             '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place',
471 471
             '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate',
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
             '*.academic_period' => 'required|exists:academic_periods,name',
476 476
             '*.education_grade' => 'required',
477 477
             '*.option_*' => 'nullable|exists:education_subjects,name',
478
-            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'],
479
-            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'],
478
+            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'],
479
+            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'],
480 480
             '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].'
481 481
             '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name',
482 482
             '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/',
Please login to merge, or discard this patch.