@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param Request $request |
| 34 | 34 | * @return \Illuminate\Http\JsonResponse |
| 35 | 35 | */ |
| 36 | - public function upload(Request $request){ |
|
| 36 | + public function upload(Request $request) { |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $institution = auth()->user()->permissions->isEmpty() ? auth()->user()->principal[0]->institution_group[0]->institution->code : auth()->user()->permissions[0]->institution_staff->institution->code; |
| 76 | 76 | |
| 77 | 77 | |
| 78 | - $fileName = time().'_'.$institution.'_'.str_replace(' ','_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
| 78 | + $fileName = time().'_'.$institution.'_'.str_replace(' ', '_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
| 79 | 79 | Storage::disk('local')->putFileAs( |
| 80 | 80 | 'sis-bulk-data-files/', |
| 81 | 81 | $uploadFile, |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | 85 | $upload = new Upload; |
| 86 | - $upload->fileName =$fileName; |
|
| 86 | + $upload->fileName = $fileName; |
|
| 87 | 87 | $upload->model = 'Student'; |
| 88 | 88 | $upload->node = 'None'; |
| 89 | 89 | $upload->institution_class_id = $class->id; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | return redirect('/')->withSuccess('The file is uploaded, we will process and let you know by your email'); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function updateQueueWithUnprocessedFiles($id, $action){ |
|
| 98 | - if($action == 100){ |
|
| 97 | + public function updateQueueWithUnprocessedFiles($id, $action) { |
|
| 98 | + if ($action == 100) { |
|
| 99 | 99 | DB::table('uploads') |
| 100 | 100 | ->where('id', $id) |
| 101 | 101 | ->update(['is_processed' => 0]); |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - public function downloadTemplate(){ |
|
| 110 | + public function downloadTemplate() { |
|
| 111 | 111 | $filename = 'censusNo_className_sis_students_bulk_upload'; |
| 112 | 112 | $version = '2007_V2.0.2_20201211.xlsx'; |
| 113 | - $file_path = storage_path() .'/app/public/'. $filename.'_'.$version;; |
|
| 113 | + $file_path = storage_path().'/app/public/'.$filename.'_'.$version; ; |
|
| 114 | 114 | if (file_exists($file_path)) |
| 115 | 115 | { |
| 116 | 116 | return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ |
| 117 | - 'Content-Length: '. filesize($file_path) |
|
| 117 | + 'Content-Length: '.filesize($file_path) |
|
| 118 | 118 | ]); |
| 119 | 119 | } |
| 120 | 120 | else |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | * @param $filename |
| 129 | 129 | * @return Processed excel file with error |
| 130 | 130 | */ |
| 131 | - public function downloadErrorFile($filename){ |
|
| 131 | + public function downloadErrorFile($filename) { |
|
| 132 | 132 | |
| 133 | - $file_path = storage_path().'/app/sis-bulk-data-files/processed/'. $filename; |
|
| 133 | + $file_path = storage_path().'/app/sis-bulk-data-files/processed/'.$filename; |
|
| 134 | 134 | if (file_exists($file_path)) |
| 135 | 135 | { |
| 136 | 136 | return Response::download($file_path, $filename, [ |
| 137 | - 'Content-Length: '. filesize($file_path) |
|
| 137 | + 'Content-Length: '.filesize($file_path) |
|
| 138 | 138 | ]); |
| 139 | 139 | } |
| 140 | 140 | else |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
| 147 | - public function downloadFile($filename){ |
|
| 148 | - $file_path = storage_path().'/app/sis-bulk-data-files/'. $filename; |
|
| 147 | + public function downloadFile($filename) { |
|
| 148 | + $file_path = storage_path().'/app/sis-bulk-data-files/'.$filename; |
|
| 149 | 149 | if (file_exists($file_path)) |
| 150 | 150 | { |
| 151 | 151 | return Response::download($file_path, $filename, [ |
| 152 | - 'Content-Length: '. filesize($file_path) |
|
| 152 | + 'Content-Length: '.filesize($file_path) |
|
| 153 | 153 | ]); |
| 154 | 154 | } |
| 155 | 155 | else |
@@ -75,7 +75,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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('id', '=', $institutionClass->academic_period_id)->first(); |
| 135 | 135 | |
| 136 | 136 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if (array_key_exists('preferred_name', $row)) { |
| 152 | 152 | $preferred_name = $row['preferred_name']; |
| 153 | 153 | } |
| 154 | - $student = Security_user::create([ |
|
| 154 | + $student = Security_user::create([ |
|
| 155 | 155 | 'username' => str_replace('-', '', $openemisStudent), |
| 156 | 156 | 'openemis_no' => $openemisStudent, |
| 157 | 157 | 'first_name' => $row['full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) { |
| 233 | 233 | try { |
| 234 | 234 | // convert Meeter to CM |
| 235 | - $hight = $row['bmi_height'] / 100; |
|
| 235 | + $hight = $row['bmi_height']/100; |
|
| 236 | 236 | //calculate BMI |
| 237 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
| 237 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
| 238 | 238 | |
| 239 | 239 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
| 240 | 240 | |
@@ -248,17 +248,17 @@ discard block |
||
| 248 | 248 | 'security_user_id' => $student->student_id, |
| 249 | 249 | 'created_user_id' => $this->file['security_user_id'] |
| 250 | 250 | ]); |
| 251 | - } catch (\Throwable $th) { |
|
| 252 | - \Log::error('User_body_mass:' . $th->getMessage()); |
|
| 251 | + }catch (\Throwable $th) { |
|
| 252 | + \Log::error('User_body_mass:'.$th->getMessage()); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 258 | 258 | |
| 259 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); |
|
| 260 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); |
|
| 261 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); |
|
| 259 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); |
|
| 260 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); |
|
| 261 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); |
|
| 262 | 262 | $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
| 263 | 263 | |
| 264 | 264 | $identityType = ($identityType !== null) ? $identityType->id : null; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | User_contact::createOrUpdate($father, $this->file['security_user_id']); |
| 297 | 297 | } |
| 298 | 298 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
| 299 | - } else { |
|
| 299 | + }else { |
|
| 300 | 300 | Security_user::where('id', '=', $father->id) |
| 301 | 301 | ->update(['is_guardian' => 1]); |
| 302 | 302 | $father['guardian_relation_id'] = 1; |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 312 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); |
|
| 313 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); |
|
| 314 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); |
|
| 312 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); |
|
| 313 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); |
|
| 314 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); |
|
| 315 | 315 | $openemisMother = $this->uniqueUid::getUniqueAlphanumeric(); |
| 316 | 316 | |
| 317 | 317 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
| 348 | 348 | } |
| 349 | 349 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
| 350 | - } else { |
|
| 350 | + }else { |
|
| 351 | 351 | Security_user::where('id', '=', $mother->id) |
| 352 | 352 | ->update(['is_guardian' => 1]); |
| 353 | 353 | $mother['guardian_relation_id'] = 2; |
@@ -362,9 +362,9 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 364 | 364 | $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; |
| 365 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); |
|
| 366 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); |
|
| 367 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); |
|
| 365 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); |
|
| 366 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); |
|
| 367 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); |
|
| 368 | 368 | $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric(); |
| 369 | 369 | |
| 370 | 370 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
| 402 | 402 | } |
| 403 | 403 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
| 404 | - } else { |
|
| 404 | + }else { |
|
| 405 | 405 | Security_user::where('id', '=', $guardian->id) |
| 406 | 406 | ->update(['is_guardian' => 1]); |
| 407 | 407 | $guardian['guardian_relation_id'] = 3; |
@@ -435,7 +435,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 463 | 463 | '*.full_name' => 'required|regex:/^[\pL\s\-]+$/u|max:256', |
| 464 | 464 | '*.preferred_name' => 'nullable|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', |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | '*.identity_number' => 'nullable|identity:identity_type|required_with:*.identity_type', |
| 473 | 473 | '*.education_grade' => 'required', |
| 474 | 474 | '*.option_*' => 'nullable|exists:education_subjects,name', |
| 475 | - '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'], |
|
| 476 | - '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'], |
|
| 475 | + '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'], |
|
| 476 | + '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'], |
|
| 477 | 477 | '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].' |
| 478 | 478 | '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name', |
| 479 | 479 | '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/', |
@@ -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 | |
| 117 | 117 | $date = $row['date_of_birth_yyyy_mm_dd']; |
| 118 | 118 | |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | ->update(['admission_id'=> $row['admission_no']]); |
| 160 | 160 | }*/ |
| 161 | 161 | |
| 162 | - if(!empty($row['admission_no'])){ |
|
| 163 | - Institution_student::where('student_id','=',$studentInfo->id) |
|
| 164 | - ->where('institution_id','=', $institution) |
|
| 162 | + if (!empty($row['admission_no'])) { |
|
| 163 | + Institution_student::where('student_id', '=', $studentInfo->id) |
|
| 164 | + ->where('institution_id', '=', $institution) |
|
| 165 | 165 | ->update(['admission_id'=> $row['admission_no']]); |
| 166 | 166 | } |
| 167 | 167 | if (!empty($row['special_need'])) { |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) { |
| 187 | 187 | |
| 188 | 188 | // convert Meeter to CM |
| 189 | - $hight = $row['bmi_height'] / 100; |
|
| 189 | + $hight = $row['bmi_height']/100; |
|
| 190 | 190 | |
| 191 | 191 | //calculate BMI |
| 192 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
| 192 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
| 193 | 193 | |
| 194 | 194 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
| 195 | - $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id ) |
|
| 196 | - ->where('security_user_id','=',$student->student_id)->count(); |
|
| 195 | + $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id) |
|
| 196 | + ->where('security_user_id', '=', $student->student_id)->count(); |
|
| 197 | 197 | |
| 198 | 198 | \Log::debug('User_body_mass'); |
| 199 | - if(!($count > 0)){ |
|
| 199 | + if (!($count > 0)) { |
|
| 200 | 200 | User_body_mass::create([ |
| 201 | 201 | 'height' => $row['bmi_height'], |
| 202 | 202 | 'weight' => $row['bmi_weight'], |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 213 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); |
|
| 214 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); |
|
| 215 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); |
|
| 216 | - $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
| 213 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); |
|
| 214 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); |
|
| 215 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); |
|
| 216 | + $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
| 217 | 217 | |
| 218 | 218 | $identityType = ($identityType !== null) ? $identityType->id : null; |
| 219 | 219 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | if ($father === null) { |
| 229 | 229 | $data = [ |
| 230 | - 'username' => str_replace('-','',$openemisFather), |
|
| 230 | + 'username' => str_replace('-', '', $openemisFather), |
|
| 231 | 231 | 'openemis_no' => $openemisFather, |
| 232 | 232 | 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
| 233 | 233 | 'last_name' => genNameWithInitials($row['fathers_full_name']), |
@@ -246,25 +246,25 @@ discard block |
||
| 246 | 246 | $father['guardian_relation_id'] = 1; |
| 247 | 247 | if (array_key_exists('fathers_phone', $row)) { |
| 248 | 248 | $father['contact'] = $row['fathers_phone']; |
| 249 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
| 249 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
| 250 | 250 | } |
| 251 | 251 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
| 252 | - } else { |
|
| 252 | + }else { |
|
| 253 | 253 | Security_user::where('id', '=', $father->id) |
| 254 | 254 | ->update(['is_guardian' => 1]); |
| 255 | 255 | $father['guardian_relation_id'] = 1; |
| 256 | 256 | if (array_key_exists('fathers_phone', $row)) { |
| 257 | 257 | $father['contact'] = $row['fathers_phone']; |
| 258 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
| 258 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
| 259 | 259 | } |
| 260 | 260 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 265 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); |
|
| 266 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); |
|
| 267 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); |
|
| 265 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); |
|
| 266 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); |
|
| 267 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); |
|
| 268 | 268 | $openemisMother = $this->uniqueUid::getUniqueAlphanumeric(); |
| 269 | 269 | |
| 270 | 270 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | if ($mother === null) { |
| 281 | 281 | $mother = Security_user::create([ |
| 282 | - 'username' => str_replace('-','',$openemisMother), |
|
| 282 | + 'username' => str_replace('-', '', $openemisMother), |
|
| 283 | 283 | 'openemis_no' => $openemisMother, |
| 284 | 284 | 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
| 285 | 285 | 'last_name' => genNameWithInitials($row['mothers_full_name']), |
@@ -297,16 +297,16 @@ discard block |
||
| 297 | 297 | $mother['guardian_relation_id'] = 2; |
| 298 | 298 | if (array_key_exists('mothers_phone', $row)) { |
| 299 | 299 | $mother['contact'] = $row['mothers_phone']; |
| 300 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
| 300 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
| 301 | 301 | } |
| 302 | 302 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
| 303 | - } else { |
|
| 303 | + }else { |
|
| 304 | 304 | Security_user::where('id', '=', $mother->id) |
| 305 | 305 | ->update(['is_guardian' => 1]); |
| 306 | 306 | $mother['guardian_relation_id'] = 2; |
| 307 | 307 | if (array_key_exists('mothers_phone', $row)) { |
| 308 | 308 | $mother['contact'] = $row['mothers_phone']; |
| 309 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
| 309 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
| 310 | 310 | } |
| 311 | 311 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
| 312 | 312 | } |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 317 | 317 | $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; |
| 318 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); |
|
| 319 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); |
|
| 320 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); |
|
| 318 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); |
|
| 319 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); |
|
| 320 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); |
|
| 321 | 321 | $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric(); |
| 322 | 322 | |
| 323 | 323 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | if ($guardian === null) { |
| 334 | 334 | $guardian = Security_user::create([ |
| 335 | - 'username' => str_replace('-','',$openemisGuardian), |
|
| 335 | + 'username' => str_replace('-', '', $openemisGuardian), |
|
| 336 | 336 | 'openemis_no' => $openemisGuardian, |
| 337 | 337 | 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
| 338 | 338 | 'last_name' => genNameWithInitials($row['guardians_full_name']), |
@@ -351,23 +351,23 @@ discard block |
||
| 351 | 351 | $guardian['guardian_relation_id'] = 3; |
| 352 | 352 | if (array_key_exists('guardians_phone', $row)) { |
| 353 | 353 | $guardian['contact'] = $row['guardians_phone']; |
| 354 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
| 354 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
| 355 | 355 | } |
| 356 | 356 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
| 357 | - } else { |
|
| 357 | + }else { |
|
| 358 | 358 | Security_user::where('id', '=', $guardian->id) |
| 359 | 359 | ->update(['is_guardian' => 1]); |
| 360 | 360 | $guardian['guardian_relation_id'] = 3; |
| 361 | 361 | if (array_key_exists('guardians_phone', $row)) { |
| 362 | 362 | $guardian['contact'] = $row['guardians_phone']; |
| 363 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
| 363 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
| 364 | 364 | } |
| 365 | 365 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | Institution_student::updateStudentArea($student); |
| 369 | 369 | |
| 370 | - $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
| 370 | + $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
| 371 | 371 | |
| 372 | 372 | $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject); |
| 373 | 373 | // $stundetSubjects = $this->getStudentSubjects($student); |
@@ -376,9 +376,9 @@ discard block |
||
| 376 | 376 | if (!empty($allSubjects)) { |
| 377 | 377 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); |
| 378 | 378 | $this->student = $student; |
| 379 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); |
|
| 379 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); |
|
| 380 | 380 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
| 381 | - array_walk($allSubjects,array($this,'insertSubject')); |
|
| 381 | + array_walk($allSubjects, array($this, 'insertSubject')); |
|
| 382 | 382 | array_walk($allSubjects, array($this, 'updateSubjectCount')); |
| 383 | 383 | } |
| 384 | 384 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | 'total_male_students' => $totalStudents['total_male_students'], |
| 392 | 392 | 'total_female_students' => $totalStudents['total_female_students']]); |
| 393 | 393 | } |
| 394 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 394 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 395 | 395 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 396 | 396 | $failures = $e->failures(); |
| 397 | 397 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |