@@ -55,7 +55,7 @@ discard block |
||
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, |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | break; |
111 | 111 | } |
112 | 112 | |
113 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
114 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
115 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
113 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
114 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
115 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
116 | 116 | $academicPeriod = Academic_period::where('name', '=', $institutionClass->academic_period_id)->first(); |
117 | 117 | |
118 | 118 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ->update([ |
133 | 133 | '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. |
134 | 134 | 'last_name' => $row['full_name'] ? genNameWithInitials($row['full_name']) : genNameWithInitials($studentInfo['first_name']), |
135 | - 'preferred_name' => $row['preferred_name'] , |
|
135 | + 'preferred_name' => $row['preferred_name'], |
|
136 | 136 | 'gender_id' => $genderId ? $genderId : $studentInfo['gender_id'], |
137 | 137 | 'date_of_birth' => $date ? $date : $studentInfo['date_of_birth'], |
138 | 138 | 'address' => $row['address'] ? $row['address'] : $studentInfo['address'], |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | |
148 | 148 | $student = Institution_class_student::where('student_id', '=', $studentInfo->id)->first(); |
149 | 149 | |
150 | - if(!empty($row['admission_no']) && !empty($academicPeriod)){ |
|
151 | - Institution_student::where('student_id','=',$studentInfo->id) |
|
152 | - ->where('institution_id','=', $institution) |
|
153 | - ->where('academic_period_id','=',$academicPeriod->id) |
|
150 | + if (!empty($row['admission_no']) && !empty($academicPeriod)) { |
|
151 | + Institution_student::where('student_id', '=', $studentInfo->id) |
|
152 | + ->where('institution_id', '=', $institution) |
|
153 | + ->where('academic_period_id', '=', $academicPeriod->id) |
|
154 | 154 | ->update(['admission_id'=> $row['admission_no']]); |
155 | 155 | } |
156 | 156 | |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) { |
177 | 177 | |
178 | 178 | // convert Meeter to CM |
179 | - $hight = $row['bmi_height'] / 100; |
|
179 | + $hight = $row['bmi_height']/100; |
|
180 | 180 | |
181 | 181 | //calculate BMI |
182 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
182 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
183 | 183 | |
184 | 184 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
185 | - $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id ) |
|
186 | - ->where('security_user_id','=',$student->student_id)->count(); |
|
185 | + $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id) |
|
186 | + ->where('security_user_id', '=', $student->student_id)->count(); |
|
187 | 187 | |
188 | 188 | \Log::debug('User_body_mass'); |
189 | - if(!($count > 0)){ |
|
189 | + if (!($count > 0)) { |
|
190 | 190 | User_body_mass::create([ |
191 | 191 | 'height' => $row['bmi_height'], |
192 | 192 | 'weight' => $row['bmi_weight'], |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { |
203 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); |
|
204 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); |
|
205 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); |
|
206 | - $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
203 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); |
|
204 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); |
|
205 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); |
|
206 | + $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
207 | 207 | |
208 | 208 | $identityType = ($identityType !== null) ? $identityType->id : null; |
209 | 209 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | if ($father === null) { |
219 | 219 | $data = [ |
220 | - 'username' => str_replace('-','',$openemisFather), |
|
220 | + 'username' => str_replace('-', '', $openemisFather), |
|
221 | 221 | 'openemis_no' => $openemisFather, |
222 | 222 | 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
223 | 223 | 'last_name' => genNameWithInitials($row['fathers_full_name']), |
@@ -236,25 +236,25 @@ discard block |
||
236 | 236 | $father['guardian_relation_id'] = 1; |
237 | 237 | if (array_key_exists('fathers_phone', $row)) { |
238 | 238 | $father['contact'] = $row['fathers_phone']; |
239 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
239 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
240 | 240 | } |
241 | 241 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
242 | - } else { |
|
242 | + }else { |
|
243 | 243 | Security_user::where('id', '=', $father->id) |
244 | 244 | ->update(['is_guardian' => 1]); |
245 | 245 | $father['guardian_relation_id'] = 1; |
246 | 246 | if (array_key_exists('fathers_phone', $row)) { |
247 | 247 | $father['contact'] = $row['fathers_phone']; |
248 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
248 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
249 | 249 | } |
250 | 250 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | 254 | if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { |
255 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); |
|
256 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); |
|
257 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); |
|
255 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); |
|
256 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); |
|
257 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); |
|
258 | 258 | $openemisMother = $this->uniqueUid::getUniqueAlphanumeric(); |
259 | 259 | |
260 | 260 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | if ($mother === null) { |
271 | 271 | $mother = Security_user::create([ |
272 | - 'username' => str_replace('-','',$openemisMother), |
|
272 | + 'username' => str_replace('-', '', $openemisMother), |
|
273 | 273 | 'openemis_no' => $openemisMother, |
274 | 274 | 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
275 | 275 | 'last_name' => genNameWithInitials($row['mothers_full_name']), |
@@ -287,16 +287,16 @@ discard block |
||
287 | 287 | $mother['guardian_relation_id'] = 2; |
288 | 288 | if (array_key_exists('mothers_phone', $row)) { |
289 | 289 | $mother['contact'] = $row['mothers_phone']; |
290 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
290 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
291 | 291 | } |
292 | 292 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
293 | - } else { |
|
293 | + }else { |
|
294 | 294 | Security_user::where('id', '=', $mother->id) |
295 | 295 | ->update(['is_guardian' => 1]); |
296 | 296 | $mother['guardian_relation_id'] = 2; |
297 | 297 | if (array_key_exists('mothers_phone', $row)) { |
298 | 298 | $mother['contact'] = $row['mothers_phone']; |
299 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
299 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
300 | 300 | } |
301 | 301 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
302 | 302 | } |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | |
306 | 306 | if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { |
307 | 307 | $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; |
308 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); |
|
309 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); |
|
310 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); |
|
308 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); |
|
309 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); |
|
310 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); |
|
311 | 311 | $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric(); |
312 | 312 | |
313 | 313 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | if ($guardian === null) { |
324 | 324 | $guardian = Security_user::create([ |
325 | - 'username' => str_replace('-','',$openemisGuardian), |
|
325 | + 'username' => str_replace('-', '', $openemisGuardian), |
|
326 | 326 | 'openemis_no' => $openemisGuardian, |
327 | 327 | 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
328 | 328 | 'last_name' => genNameWithInitials($row['guardians_full_name']), |
@@ -341,22 +341,22 @@ discard block |
||
341 | 341 | $guardian['guardian_relation_id'] = 3; |
342 | 342 | if (array_key_exists('guardians_phone', $row)) { |
343 | 343 | $guardian['contact'] = $row['guardians_phone']; |
344 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
344 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
345 | 345 | } |
346 | 346 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
347 | - } else { |
|
347 | + }else { |
|
348 | 348 | Security_user::where('id', '=', $guardian->id) |
349 | 349 | ->update(['is_guardian' => 1]); |
350 | 350 | $guardian['guardian_relation_id'] = 3; |
351 | 351 | if (array_key_exists('guardians_phone', $row)) { |
352 | 352 | $guardian['contact'] = $row['guardians_phone']; |
353 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
353 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
354 | 354 | } |
355 | 355 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
359 | + $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
360 | 360 | |
361 | 361 | $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject); |
362 | 362 | // $stundetSubjects = $this->getStudentSubjects($student); |
@@ -365,10 +365,10 @@ discard block |
||
365 | 365 | if (!empty($allSubjects)) { |
366 | 366 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); |
367 | 367 | $this->student = $student; |
368 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); |
|
368 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); |
|
369 | 369 | // $allSubjects = array_unique($allSubjects,SORT_REGULAR); |
370 | 370 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
371 | - array_walk($allSubjects,array($this,'insertSubject')); |
|
371 | + array_walk($allSubjects, array($this, 'insertSubject')); |
|
372 | 372 | array_walk($allSubjects, array($this, 'updateSubjectCount')); |
373 | 373 | } |
374 | 374 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | 'total_male_students' => $totalStudents['total_male_students'], |
382 | 382 | 'total_female_students' => $totalStudents['total_female_students']]); |
383 | 383 | } |
384 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
384 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
385 | 385 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
386 | 386 | $failures = $e->failures(); |
387 | 387 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |