Test Setup Failed
Pull Request — master (#513)
by
unknown
20:20 queued 13:49
created
app/Imports/StudentUpdate.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 use Maatwebsite\Excel\Concerns\WithMultipleSheets;
56 56
 use Maatwebsite\Excel\Concerns\RegistersEventListeners;
57 57
 
58
-class StudentUpdate extends Import implements  ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation , SkipsOnFailure , SkipsOnError{
58
+class StudentUpdate extends Import implements  ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation, SkipsOnFailure, SkipsOnError{
59 59
 
60 60
     use Importable,
61 61
         RegistersEventListeners,
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
                         break;
109 109
                 }
110 110
 
111
-                $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first();
112
-                $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first();
113
-                $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first();
111
+                $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first();
112
+                $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first();
113
+                $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first();
114 114
                 $academicPeriod = Academic_period::where('name', '=', $institutionClass->academic_period_id)->first();
115 115
 
116 116
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                         ->update([
131 131
                             'first_name' => $row['full_name'] ? $row['full_name'] : $studentInfo['first_name'], // here we save full name in the column of first name. re reduce breaks of the system.
132 132
                             'last_name' => $row['full_name'] ? genNameWithInitials($row['full_name']) : genNameWithInitials($studentInfo['first_name']),
133
-                            'preferred_name' => $row['preferred_name'] ,
133
+                            'preferred_name' => $row['preferred_name'],
134 134
                             'gender_id' => $genderId ? $genderId : $studentInfo['gender_id'],
135 135
                             'date_of_birth' => $date ? $date : $studentInfo['date_of_birth'],
136 136
                             'address' => $row['address'] ? $row['address'] : $studentInfo['address'],
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 
146 146
                 $student = Institution_class_student::where('student_id', '=', $studentInfo->id)->first();
147 147
 
148
-                if(!empty($row['admission_no']) && !empty($academicPeriod)){
149
-                    Institution_student::where('student_id','=',$studentInfo->id)
150
-                    ->where('institution_id','=', $institution)
151
-                    ->where('academic_period_id','=',$academicPeriod->id)
148
+                if (!empty($row['admission_no']) && !empty($academicPeriod)) {
149
+                    Institution_student::where('student_id', '=', $studentInfo->id)
150
+                    ->where('institution_id', '=', $institution)
151
+                    ->where('academic_period_id', '=', $academicPeriod->id)
152 152
                     ->update(['admission_id'=> $row['admission_no']]);
153 153
                 }
154 154
                 
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
                 if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) {
175 175
 
176 176
                     // convert Meeter to CM
177
-                    $hight = $row['bmi_height'] / 100;
177
+                    $hight = $row['bmi_height']/100;
178 178
 
179 179
                     //calculate BMI
180
-                    $bodyMass = ($row['bmi_weight']) / pow($hight, 2);
180
+                    $bodyMass = ($row['bmi_weight'])/pow($hight, 2);
181 181
 
182 182
                     $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first();
183
-                    $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id )
184
-                            ->where('security_user_id','=',$student->student_id)->count();
183
+                    $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id)
184
+                            ->where('security_user_id', '=', $student->student_id)->count();
185 185
 
186 186
                     \Log::debug('User_body_mass');
187
-                    if(!($count > 0)){
187
+                    if (!($count > 0)) {
188 188
                         User_body_mass::create([
189 189
                             'height' => $row['bmi_height'],
190 190
                             'weight' => $row['bmi_weight'],
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
                 }
199 199
 
200 200
                 if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) {
201
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first();
202
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first();
203
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first();
204
-                    $openemisFather =  $this->uniqueUid::getUniqueAlphanumeric();
201
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first();
202
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first();
203
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first();
204
+                    $openemisFather = $this->uniqueUid::getUniqueAlphanumeric();
205 205
 
206 206
                     $identityType = ($identityType !== null) ? $identityType->id : null;
207 207
                     $nationalityId = $nationalityId !== null ? $nationalityId->id : null;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
                     if ($father === null) {
217 217
                         $data = [
218
-                            'username' => str_replace('-','',$openemisFather),
218
+                            'username' => str_replace('-', '', $openemisFather),
219 219
                             'openemis_no' => $openemisFather,
220 220
                             'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
221 221
                             'last_name' => genNameWithInitials($row['fathers_full_name']),
@@ -234,25 +234,25 @@  discard block
 block discarded – undo
234 234
                         $father['guardian_relation_id'] = 1;
235 235
                         if (array_key_exists('fathers_phone', $row)) {
236 236
                             $father['contact'] = $row['fathers_phone'];
237
-                            User_contact::createOrUpdate($father,$this->file['security_user_id']);
237
+                            User_contact::createOrUpdate($father, $this->file['security_user_id']);
238 238
                         }
239 239
                         Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
240
-                    } else {
240
+                    }else {
241 241
                         Security_user::where('id', '=', $father->id)
242 242
                                 ->update(['is_guardian' => 1]);
243 243
                         $father['guardian_relation_id'] = 1;
244 244
                         if (array_key_exists('fathers_phone', $row)) {
245 245
                             $father['contact'] = $row['fathers_phone'];
246
-                            User_contact::createOrUpdate($father,$this->file['security_user_id']);
246
+                            User_contact::createOrUpdate($father, $this->file['security_user_id']);
247 247
                         }
248 248
                         Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
249 249
                     }
250 250
                 }
251 251
 
252 252
                 if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) {
253
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first();
254
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first();
255
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first();
253
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first();
254
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first();
255
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first();
256 256
                     $openemisMother = $this->uniqueUid::getUniqueAlphanumeric();
257 257
 
258 258
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
                     if ($mother === null) {
269 269
                         $mother = Security_user::create([
270
-                                    'username' => str_replace('-','',$openemisMother),
270
+                                    'username' => str_replace('-', '', $openemisMother),
271 271
                                     'openemis_no' => $openemisMother,
272 272
                                     'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
273 273
                                     'last_name' => genNameWithInitials($row['mothers_full_name']),
@@ -285,16 +285,16 @@  discard block
 block discarded – undo
285 285
                         $mother['guardian_relation_id'] = 2;
286 286
                         if (array_key_exists('mothers_phone', $row)) {
287 287
                             $mother['contact'] = $row['mothers_phone'];
288
-                            User_contact::createOrUpdate($mother,$this->file['security_user_id']);
288
+                            User_contact::createOrUpdate($mother, $this->file['security_user_id']);
289 289
                         }   
290 290
                         Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
291
-                    } else {
291
+                    }else {
292 292
                         Security_user::where('id', '=', $mother->id)
293 293
                                 ->update(['is_guardian' => 1]);
294 294
                         $mother['guardian_relation_id'] = 2;
295 295
                         if (array_key_exists('mothers_phone', $row)) {
296 296
                             $mother['contact'] = $row['mothers_phone'];
297
-                            User_contact::createOrUpdate($mother,$this->file['security_user_id']);
297
+                            User_contact::createOrUpdate($mother, $this->file['security_user_id']);
298 298
                         }
299 299
                         Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
300 300
                     }
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 
304 304
                 if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) {
305 305
                     $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2;
306
-                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first();
307
-                    $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first();
308
-                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first();
306
+                    $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first();
307
+                    $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first();
308
+                    $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first();
309 309
                     $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric();
310 310
 
311 311
                     $identityType = $identityType !== null ? $identityType->id : null;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 
321 321
                     if ($guardian === null) {
322 322
                         $guardian = Security_user::create([
323
-                                    'username' => str_replace('-','',$openemisGuardian),
323
+                                    'username' => str_replace('-', '', $openemisGuardian),
324 324
                                     'openemis_no' => $openemisGuardian,
325 325
                                     'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
326 326
                                     'last_name' => genNameWithInitials($row['guardians_full_name']),
@@ -339,22 +339,22 @@  discard block
 block discarded – undo
339 339
                         $guardian['guardian_relation_id'] = 3;
340 340
                         if (array_key_exists('guardians_phone', $row)) {
341 341
                             $guardian['contact'] = $row['guardians_phone'];
342
-                            User_contact::createOrUpdate($guardian,$this->file['security_user_id']);
342
+                            User_contact::createOrUpdate($guardian, $this->file['security_user_id']);
343 343
                         }  
344 344
                         Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
345
-                    } else {
345
+                    }else {
346 346
                         Security_user::where('id', '=', $guardian->id)
347 347
                                 ->update(['is_guardian' => 1]);
348 348
                         $guardian['guardian_relation_id'] = 3;
349 349
                         if (array_key_exists('guardians_phone', $row)) {
350 350
                             $guardian['contact'] = $row['guardians_phone'];
351
-                            User_contact::createOrUpdate($guardian,$this->file['security_user_id']);
351
+                            User_contact::createOrUpdate($guardian, $this->file['security_user_id']);
352 352
                         } 
353 353
                         Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
354 354
                     }
355 355
                 }
356 356
 
357
-                $optionalSubjects =  Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution);
357
+                $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution);
358 358
 
359 359
                 $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject);
360 360
                 // $stundetSubjects = $this->getStudentSubjects($student);
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
                 if (!empty($allSubjects)) {
364 364
                     $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id');
365 365
                     $this->student = $student;
366
-                    $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects);
366
+                    $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects);
367 367
                     // $allSubjects = array_unique($allSubjects,SORT_REGULAR);
368 368
                     $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id');
369
-                    array_walk($allSubjects,array($this,'insertSubject'));
369
+                    array_walk($allSubjects, array($this, 'insertSubject'));
370 370
                     array_walk($allSubjects, array($this, 'updateSubjectCount'));
371 371
                 }
372 372
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
                             'total_male_students' => $totalStudents['total_male_students'],
380 380
                             'total_female_students' => $totalStudents['total_female_students']]);
381 381
             }
382
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
382
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
383 383
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
384 384
             $failures = $e->failures();
385 385
             throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
Please login to merge, or discard this patch.