@@ -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 |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | if (empty($value)) { |
| 72 | 72 | return false; |
| 73 | 73 | } elseif ($gradeEntity !== null) { |
| 74 | - $admissionAge = (($gradeEntity->admission_age) * 12) - 1; |
|
| 74 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
| 75 | 75 | $to = $academicPeriod->start_date; |
| 76 | 76 | $diff_in_months = $to->diffInMonths($value); |
| 77 | 77 | $ageOfStudent = $diff_in_months; |
| 78 | 78 | $enrolmentMaximumAge = $admissionAge + 120; |
| 79 | 79 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
| 80 | - } else { |
|
| 80 | + }else { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | - } else { |
|
| 84 | - $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found'; |
|
| 83 | + }else { |
|
| 84 | + $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found'; |
|
| 85 | 85 | $this->_set_custom_stuff(); |
| 86 | 86 | return false; |
| 87 | 87 | } |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | if (is_numeric($value)) { |
| 94 | 94 | if ($value < 10) { |
| 95 | - $this->_custom_messages['bmi'] = $attribute . ' is must greater than 10'; |
|
| 95 | + $this->_custom_messages['bmi'] = $attribute.' is must greater than 10'; |
|
| 96 | 96 | $this->_set_custom_stuff(); |
| 97 | 97 | return false; |
| 98 | 98 | } elseif ($value > 250) { |
| 99 | - $this->_custom_messages['bmi'] = $attribute . ' is must smaller than 250'; |
|
| 99 | + $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250'; |
|
| 100 | 100 | $this->_set_custom_stuff(); |
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | - } else { |
|
| 104 | - $this->_custom_messages['bmi'] = $attribute . ' is must a valid numeric'; |
|
| 103 | + }else { |
|
| 104 | + $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric'; |
|
| 105 | 105 | $this->_set_custom_stuff(); |
| 106 | 106 | return false; |
| 107 | 107 | } |
@@ -110,18 +110,18 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | protected function validateBmi($attribute, $value, $parameters) |
| 112 | 112 | { |
| 113 | - $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
| 113 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
| 114 | 114 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
| 115 | 115 | ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
| 116 | 116 | ->first(); |
| 117 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
| 117 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
| 118 | 118 | if (in_array($institutionGrade->code, $bmiGrades)) { |
| 119 | 119 | if (!empty($value)) { |
| 120 | 120 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
| 121 | 121 | return $this->validateHW($attribute, $value); |
| 122 | 122 | } |
| 123 | - } else { |
|
| 124 | - $this->_custom_messages['bmi'] = $attribute . ' is required for ' . $educationGrade->name; |
|
| 123 | + }else { |
|
| 124 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
| 125 | 125 | $this->_set_custom_stuff(); |
| 126 | 126 | return false; |
| 127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
| 130 | 130 | return $this->validateHW($attribute, $value); |
| 131 | 131 | } |
| 132 | - } else { |
|
| 132 | + }else { |
|
| 133 | 133 | return true; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -138,19 +138,19 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | foreach ($validator->getData() as $data) { |
| 140 | 140 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
| 141 | - $BirthDivision = Area_administrative::where('name', '=', '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); // |
|
| 141 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
| 142 | 142 | if ($BirthDivision->count() > 0) { |
| 143 | - $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
| 143 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
| 144 | 144 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
| 145 | - return $BirthArea > 0; |
|
| 145 | + return $BirthArea > 0; |
|
| 146 | 146 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
| 147 | 147 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
| 148 | 148 | $this->_set_custom_stuff(); |
| 149 | 149 | return false; |
| 150 | - } else { |
|
| 150 | + }else { |
|
| 151 | 151 | return true; |
| 152 | 152 | } |
| 153 | - } else { |
|
| 153 | + }else { |
|
| 154 | 154 | return true; |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) |
| 160 | 160 | { |
| 161 | - $student = Security_user::where('openemis_no', '=', $value); |
|
| 161 | + $student = Security_user::where('openemis_no', '=', $value); |
|
| 162 | 162 | if ($student->count() > 0) { |
| 163 | 163 | $student = $student->first()->toArray(); |
| 164 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
| 164 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
| 165 | 165 | if ($check == 1) { |
| 166 | 166 | return true; |
| 167 | - } else { |
|
| 167 | + }else { |
|
| 168 | 168 | return false; |
| 169 | 169 | } |
| 170 | - } else { |
|
| 170 | + }else { |
|
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | $valid = true; |
| 180 | 180 | foreach ($validator->getData() as $data) { |
| 181 | - switch($data[$perameters[0]]){ |
|
| 181 | + switch ($data[$perameters[0]]) { |
|
| 182 | 182 | case 'BC': |
| 183 | 183 | $valid = preg_match('/^([0-9]{10,12})$/i', $value); |
| 184 | 184 | break; |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | if (!$valid) { |
| 194 | - $this->_custom_messages['nic'] = $attribute . ' is not valid, Please check the NIC number'; |
|
| 194 | + $this->_custom_messages['nic'] = $attribute.' is not valid, Please check the NIC number'; |
|
| 195 | 195 | $this->_set_custom_stuff(); |
| 196 | 196 | return false; |
| 197 | - } else { |
|
| 197 | + }else { |
|
| 198 | 198 | return true; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | protected function validateUserUnique($attribute, $value, $perameters, $validator) |
| 203 | 203 | { |
| 204 | 204 | foreach ($validator->getData() as $data) { |
| 205 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 205 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 206 | 206 | if ($identityType !== null && ($value !== null)) { |
| 207 | 207 | if ($identityType->national_code === 'BC') { |
| 208 | 208 | return $this->checkUnique($value, $data, $identityType); |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | protected function validateIsBc($attribute, $value, $perameters, $validator) |
| 219 | 219 | { |
| 220 | 220 | foreach ($validator->getData() as $data) { |
| 221 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 221 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 222 | 222 | if (($identityType !== null) && ($identityType !== "")) { |
| 223 | 223 | if (($identityType->national_code) === 'BC') { |
| 224 | 224 | return (strlen((string) $data['identity_number']) < 7); |
| 225 | - } else { |
|
| 225 | + }else { |
|
| 226 | 226 | return true; |
| 227 | 227 | } |
| 228 | - } else { |
|
| 228 | + }else { |
|
| 229 | 229 | return true; |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -235,24 +235,24 @@ discard block |
||
| 235 | 235 | { |
| 236 | 236 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
| 237 | 237 | if ($isUnique->count() > 0) { |
| 238 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
| 238 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
| 239 | 239 | $this->_set_custom_stuff(); |
| 240 | 240 | return false; |
| 241 | - } else { |
|
| 241 | + }else { |
|
| 242 | 242 | return true; |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | protected function IsBc($data, $value) |
| 247 | 247 | { |
| 248 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 248 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 249 | 249 | if ($identityType !== null) { |
| 250 | 250 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
| 251 | 251 | return false; |
| 252 | - } else { |
|
| 252 | + }else { |
|
| 253 | 253 | return true; |
| 254 | 254 | } |
| 255 | - } else { |
|
| 255 | + }else { |
|
| 256 | 256 | return true; |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
| 90 | 90 | $higestRow = 0; |
| 91 | 91 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
| 92 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
| 92 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
| 93 | 93 | if (isEmptyRow(reset($rowData))) { |
| 94 | 94 | continue; |
| 95 | - } else { |
|
| 95 | + }else { |
|
| 96 | 96 | $higestRow += 1; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $this->failures = []; |
| 107 | 107 | if (($column !== "") && (!in_array($column, $columns))) { |
| 108 | 108 | $this->isValidSheet = false; |
| 109 | - $this->error[] = 'Unsupported column found ,remove:' . $column; |
|
| 109 | + $this->error[] = 'Unsupported column found ,remove:'.$column; |
|
| 110 | 110 | $this->failure = new Failure(3, 'remark', $this->error, [null]); |
| 111 | 111 | $this->failures = new \Maatwebsite\Excel\Validators\ValidationException($error, [$this->failure]); |
| 112 | 112 | } |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $columns = Config::get('excel.columns'); |
| 121 | 121 | $optional_columns = Config::get('excel.optional_columns'); |
| 122 | - $columns = array_diff ($columns,$optional_columns); |
|
| 122 | + $columns = array_diff($columns, $optional_columns); |
|
| 123 | 123 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 124 | 124 | $this->failures = []; |
| 125 | 125 | foreach ($columns as $column) { |
| 126 | 126 | if (($column !== "") && (!in_array($column, $existingColumns))) { |
| 127 | 127 | $this->isValidSheet = false; |
| 128 | - $this->error[] = 'Missing Column :' . $column . ' Not found'; |
|
| 128 | + $this->error[] = 'Missing Column :'.$column.' Not found'; |
|
| 129 | 129 | $this->failure = new Failure(3, 'remark', $this->error, [null]); |
| 130 | 130 | $this->failures = new \Maatwebsite\Excel\Validators\ValidationException($error, [$this->failure]); |
| 131 | 131 | } |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
| 143 | 143 | $higestRow = 1; |
| 144 | 144 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
| 145 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
| 145 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
| 146 | 146 | if (isEmptyRow(reset($rowData))) { |
| 147 | 147 | continue; |
| 148 | - } else { |
|
| 148 | + }else { |
|
| 149 | 149 | $higestRow += 1; |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | if ($higestRow == 0) { |
| 153 | 153 | exit; |
| 154 | - } else { |
|
| 154 | + }else { |
|
| 155 | 155 | return $higestRow; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | case 'string': |
| 177 | 177 | $row[$column] = preg_replace('/[^A-Za-z0-9\-]/', '-', $row[$column]); |
| 178 | 178 | $row[$column] = date($format, strtotime($row[$column])); //date($row[$column]); |
| 179 | - $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
| 179 | + $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
| 180 | 180 | break; |
| 181 | 181 | case 'double'; |
| 182 | - $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
| 182 | + $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
| 183 | 183 | break; |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | return $row; |
| 187 | - } catch (Exception $e) { |
|
| 187 | + }catch (Exception $e) { |
|
| 188 | 188 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 189 | - $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system ' . $row[$column] . ' Not a valid date formate'], [null]); |
|
| 189 | + $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system '.$row[$column].' Not a valid date formate'], [null]); |
|
| 190 | 190 | $failures = [0 => $failure]; |
| 191 | 191 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 192 | 192 | } |
@@ -207,18 +207,18 @@ discard block |
||
| 207 | 207 | $row = $this->formateDate($row, 'mothers_date_of_birth_yyyy_mm_dd'); |
| 208 | 208 | $row = $this->formateDate($row, 'guardians_date_of_birth_yyyy_mm_dd'); |
| 209 | 209 | |
| 210 | - $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
| 210 | + $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
| 211 | 211 | |
| 212 | 212 | if (array_key_exists('identity_type', $row)) { |
| 213 | 213 | if ($row['identity_type'] == 'BC' && (!empty($row['birth_divisional_secretariat'])) && ($row['identity_number'] !== null) && $row['date_of_birth_yyyy_mm_dd'] !== null) { |
| 214 | - $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
| 214 | + $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
| 215 | 215 | // dd(($row['date_of_birth_yyyy_mm_dd'])); |
| 216 | - $BirthDivision = Area_administrative::where('name', 'like', '%' . $row['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5)->first(); |
|
| 216 | + $BirthDivision = Area_administrative::where('name', 'like', '%'.$row['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5)->first(); |
|
| 217 | 217 | if ($BirthDivision !== null) { |
| 218 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%') |
|
| 218 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%') |
|
| 219 | 219 | ->where('parent_id', '=', $BirthDivision->id)->first(); |
| 220 | 220 | if ($BirthArea !== null) { |
| 221 | - $row['identity_number'] = $BirthArea->id . '' . $row['identity_number'] . '' . substr($row['date_of_birth_yyyy_mm_dd']->format("yy"), -2) . '' . $row['date_of_birth_yyyy_mm_dd']->format("m"); |
|
| 221 | + $row['identity_number'] = $BirthArea->id.''.$row['identity_number'].''.substr($row['date_of_birth_yyyy_mm_dd']->format("yy"), -2).''.$row['date_of_birth_yyyy_mm_dd']->format("m"); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | { |
| 232 | 232 | if (array_key_exists($key, $row)) { |
| 233 | 233 | return true; |
| 234 | - } else { |
|
| 234 | + }else { |
|
| 235 | 235 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 236 | - $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system ' . $key, ' Is missing form the template'], [null]); |
|
| 236 | + $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system '.$key, ' Is missing form the template'], [null]); |
|
| 237 | 237 | $failures = [0 => $failure]; |
| 238 | 238 | new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 239 | 239 | }; |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | $exceededStudents = ($totalStudents + $this->limit()) > $institutionClass->no_of_students ? true : false; |
| 269 | 269 | if ($exceededStudents == true) { |
| 270 | 270 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 271 | - $failure = new Failure(3, 'remark', ['Class student count exceeded! Max number of students is' . $institutionClass->no_of_students], [null]); |
|
| 271 | + $failure = new Failure(3, 'remark', ['Class student count exceeded! Max number of students is'.$institutionClass->no_of_students], [null]); |
|
| 272 | 272 | $failures = [0 => $failure]; |
| 273 | 273 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 274 | 274 | Log::info('email-sent', [$this->file]); |
| 275 | - } else { |
|
| 275 | + }else { |
|
| 276 | 276 | return true; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -331,20 +331,20 @@ discard block |
||
| 331 | 331 | $this->updateSubjectCount($subject); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - public function createOrUpdateGuardian($row,$student,$param){ |
|
| 334 | + public function createOrUpdateGuardian($row, $student, $param) { |
|
| 335 | 335 | if (!empty($row[$param.'s_full_name']) && ($row[$param.'s_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 336 | 336 | $guardian = Security_user::createOrUpdateGuardianProfile($row, $param, $this->file); |
| 337 | 337 | if (!is_null($guardian)) { |
| 338 | 338 | Security_user::where('id', '=', $guardian->id) |
| 339 | 339 | ->update(['is_guardian' => 1]); |
| 340 | - $guardian['guardian_relation_id'] = $this->setRelation($param,$guardian); |
|
| 340 | + $guardian['guardian_relation_id'] = $this->setRelation($param, $guardian); |
|
| 341 | 341 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - protected function setRelation($param,$guardian){ |
|
| 347 | - switch($param){ |
|
| 346 | + protected function setRelation($param, $guardian) { |
|
| 347 | + switch ($param) { |
|
| 348 | 348 | case 'father': |
| 349 | 349 | return 1; |
| 350 | 350 | case 'mother': |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - protected function setGender($row){ |
|
| 357 | + protected function setGender($row) { |
|
| 358 | 358 | switch ($row['gender_mf']) { |
| 359 | 359 | case 'M': |
| 360 | 360 | $row['gender_mf'] = 1; |
@@ -368,17 +368,17 @@ discard block |
||
| 368 | 368 | return $row; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - protected function insertOrUpdateSubjects($row,$student,$institution){ |
|
| 371 | + protected function insertOrUpdateSubjects($row, $student, $institution) { |
|
| 372 | 372 | $mandatorySubject = Institution_class_subject::getMandatorySubjects($this->file['institution_class_id']); |
| 373 | 373 | $subjects = getMatchingKeys($row); |
| 374 | - $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
| 374 | + $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
| 375 | 375 | $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject); |
| 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 | } |
@@ -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([]); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $row = $this->setGender($row); |
| 116 | 116 | $mandatorySubject = Institution_class_subject::getMandatorySubjects($this->file['institution_class_id']); |
| 117 | 117 | $subjects = getMatchingKeys($row); |
| 118 | - $student = Security_user::createOrUpdateStudentProfile($row,'create',$this->file); |
|
| 118 | + $student = Security_user::createOrUpdateStudentProfile($row, 'create', $this->file); |
|
| 119 | 119 | $academicPeriod = Academic_period::where('id', '=', $institutionClass->academic_period_id)->first(); |
| 120 | 120 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass->id)->first(); |
| 121 | 121 | $assignee_id = $institutionClass->staff_id ? $institutionClass->staff_id : $this->file['security_user_id']; |
@@ -128,24 +128,24 @@ discard block |
||
| 128 | 128 | 'institution_class' => $institutionClass |
| 129 | 129 | ]; |
| 130 | 130 | |
| 131 | - Institution_student_admission::createAdmission($student->id,$row,$params,$this->file); |
|
| 132 | - Institution_student::createOrUpdate($student->id,$row,$params,$this->file); |
|
| 133 | - $student = Institution_class_student::createOrUpdate($student->id,$params,$this->file); |
|
| 134 | - User_special_need::createOrUpdate($student->student_id,$row,$this->file); |
|
| 135 | - User_body_mass::createOrUpdate($student->student_id,$row,$this->file); |
|
| 131 | + Institution_student_admission::createAdmission($student->id, $row, $params, $this->file); |
|
| 132 | + Institution_student::createOrUpdate($student->id, $row, $params, $this->file); |
|
| 133 | + $student = Institution_class_student::createOrUpdate($student->id, $params, $this->file); |
|
| 134 | + User_special_need::createOrUpdate($student->student_id, $row, $this->file); |
|
| 135 | + User_body_mass::createOrUpdate($student->student_id, $row, $this->file); |
|
| 136 | 136 | |
| 137 | - $this->createOrUpdateGuardian($row,$student,'father'); |
|
| 138 | - $this->createOrUpdateGuardian($row,$student,'mother'); |
|
| 139 | - $this->createOrUpdateGuardian($row,$student,'guardian'); |
|
| 137 | + $this->createOrUpdateGuardian($row, $student, 'father'); |
|
| 138 | + $this->createOrUpdateGuardian($row, $student, 'mother'); |
|
| 139 | + $this->createOrUpdateGuardian($row, $student, 'guardian'); |
|
| 140 | 140 | |
| 141 | 141 | Institution_student::updateStudentArea($student->toArray()); |
| 142 | 142 | |
| 143 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
| 143 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
| 144 | 144 | |
| 145 | 145 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
| 146 | 146 | if ($totalStudents['total'] > $institutionClass->no_of_students) { |
| 147 | 147 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 148 | - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); |
|
| 148 | + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); |
|
| 149 | 149 | $failures = [0 => $failure]; |
| 150 | 150 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 151 | 151 | Log::info('email-sent', [$this->file]); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $institutionClass = new Institution_class(); |
| 155 | 155 | $institutionClass->updateClassCount($this->file); |
| 156 | 156 | } |
| 157 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 157 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 158 | 158 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 159 | 159 | $failures = $e->failures(); |
| 160 | 160 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | '*.full_name' => 'required|regex:/^[a-zA-Z .]*$/u|max:256', |
| 170 | 170 | '*.preferred_name' => 'nullable|regex:/^[a-zA-Z .]*$/u|max:90', |
| 171 | 171 | '*.gender_mf' => 'required|in:M,F', |
| 172 | - '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'], |
|
| 172 | + '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'], |
|
| 173 | 173 | '*.address' => 'nullable', |
| 174 | 174 | '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place', |
| 175 | 175 | '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate', |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | '*.identity_number' => 'nullable|identity:identity_type|required_with:identity_type', |
| 179 | 179 | '*.education_grade' => 'required', |
| 180 | 180 | '*.option_*' => 'nullable|exists:education_subjects,name', |
| 181 | - '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'], |
|
| 182 | - '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'], |
|
| 181 | + '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'], |
|
| 182 | + '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'], |
|
| 183 | 183 | '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].' |
| 184 | 184 | '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name', |
| 185 | 185 | '*.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, |
@@ -89,29 +89,29 @@ discard block |
||
| 89 | 89 | $institution = $institutionClass->institution_id; |
| 90 | 90 | if (!empty($institutionClass)) { |
| 91 | 91 | $this->setGender($row); |
| 92 | - $studentInfo = Security_user::createOrUpdateStudentProfile($row,'update',$this->file); |
|
| 92 | + $studentInfo = Security_user::createOrUpdateStudentProfile($row, 'update', $this->file); |
|
| 93 | 93 | $student = Institution_class_student::where('student_id', '=', $studentInfo->id)->first(); |
| 94 | - if(!empty($row['admission_no'])){ |
|
| 95 | - Institution_student::where('student_id','=',$studentInfo->id) |
|
| 96 | - ->where('institution_id','=', $institution) |
|
| 94 | + if (!empty($row['admission_no'])) { |
|
| 95 | + Institution_student::where('student_id', '=', $studentInfo->id) |
|
| 96 | + ->where('institution_id', '=', $institution) |
|
| 97 | 97 | ->update(['admission_id'=> $row['admission_no']]); |
| 98 | 98 | } |
| 99 | - User_special_need::createOrUpdate($studentInfo->id,$row,$this->file); |
|
| 100 | - User_body_mass::createOrUpdate($studentInfo->id,$row,$this->file); |
|
| 99 | + User_special_need::createOrUpdate($studentInfo->id, $row, $this->file); |
|
| 100 | + User_body_mass::createOrUpdate($studentInfo->id, $row, $this->file); |
|
| 101 | 101 | |
| 102 | - $this->createOrUpdateGuardian($row,$student,'father'); |
|
| 103 | - $this->createOrUpdateGuardian($row,$student,'mother'); |
|
| 104 | - $this->createOrUpdateGuardian($row,$student,'guardian'); |
|
| 102 | + $this->createOrUpdateGuardian($row, $student, 'father'); |
|
| 103 | + $this->createOrUpdateGuardian($row, $student, 'mother'); |
|
| 104 | + $this->createOrUpdateGuardian($row, $student, 'guardian'); |
|
| 105 | 105 | |
| 106 | 106 | Institution_student::updateStudentArea($student->toArray()); |
| 107 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
| 107 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
| 108 | 108 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
| 109 | 109 | Institution_class::where('id', '=', $institutionClass->id) |
| 110 | 110 | ->update([ |
| 111 | 111 | 'total_male_students' => $totalStudents['total_male_students'], |
| 112 | 112 | 'total_female_students' => $totalStudents['total_female_students']]); |
| 113 | 113 | } |
| 114 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 114 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 115 | 115 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 116 | 116 | $failures = $e->failures(); |
| 117 | 117 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $studentData['id'] = $id; |
| 205 | 205 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
| 206 | 206 | return $studentData; |
| 207 | - } catch (\Exception $th) { |
|
| 207 | + }catch (\Exception $th) { |
|
| 208 | 208 | Log::error($th->getMessage()); |
| 209 | 209 | // in case of duplication of the Unique ID this will recursive. |
| 210 | 210 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $this->uniqueUserId = new Unique_user_id(); |
| 226 | 226 | $this->uniqueUId = new UniqueUid(); |
| 227 | 227 | // regenerate unique id if it's not available |
| 228 | - $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
| 228 | + $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
| 229 | 229 | |
| 230 | 230 | $studentData = [ |
| 231 | 231 | 'username' => str_replace('-', '', $uniqueId), |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $studentData['id'] = $sis_student['student_id']; |
| 244 | 244 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
| 245 | 245 | return $studentData; |
| 246 | - } catch (\Exception $th) { |
|
| 246 | + }catch (\Exception $th) { |
|
| 247 | 247 | Log::error($th); |
| 248 | 248 | // in case of duplication of the Unique ID this will recursive. |
| 249 | 249 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | try { |
| 257 | 257 | $uniqueUid = new UniqueUid(); |
| 258 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
| 259 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
| 260 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
| 258 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
| 259 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
| 260 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
| 261 | 261 | |
| 262 | 262 | $date = $row['date_of_birth_yyyy_mm_dd']; |
| 263 | 263 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | ]); |
| 290 | 290 | case 'update': |
| 291 | 291 | if (!is_null($row['student_id'])) { |
| 292 | - $studentInfo = Security_user::where('openemis_no',trim($row['student_id']))->first(); |
|
| 292 | + $studentInfo = Security_user::where('openemis_no', trim($row['student_id']))->first(); |
|
| 293 | 293 | self::query()->where('openemis_no', $row['student_id']) |
| 294 | 294 | ->update([ |
| 295 | 295 | '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. |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | - } catch (\Exception $e) { |
|
| 313 | + }catch (\Exception $e) { |
|
| 314 | 314 | dd($e); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -319,48 +319,48 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | try { |
| 321 | 321 | $uniqueUid = new UniqueUid(); |
| 322 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row[$prefix . 's_address_area'] . '%')->first(); |
|
| 323 | - $nationalityId = Nationality::where('name', 'like', '%' . $row[$prefix . 's_nationality'] . '%')->first(); |
|
| 324 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row[$prefix . 's_identity_type'] . '%')->first(); |
|
| 322 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row[$prefix.'s_address_area'].'%')->first(); |
|
| 323 | + $nationalityId = Nationality::where('name', 'like', '%'.$row[$prefix.'s_nationality'].'%')->first(); |
|
| 324 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row[$prefix.'s_identity_type'].'%')->first(); |
|
| 325 | 325 | $openemisNo = $uniqueUid::getUniqueAlphanumeric(); |
| 326 | 326 | |
| 327 | 327 | $identityType = ($identityType !== null) ? $identityType->id : null; |
| 328 | 328 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
| 329 | 329 | |
| 330 | 330 | $guardian = null; |
| 331 | - if (!empty($row[$prefix . 's_identity_number'])) { |
|
| 331 | + if (!empty($row[$prefix.'s_identity_number'])) { |
|
| 332 | 332 | $guardian = Security_user::where('identity_type_id', '=', $nationalityId) |
| 333 | - ->where('identity_number', '=', $row[$prefix . 's_identity_number'])->first(); |
|
| 333 | + ->where('identity_number', '=', $row[$prefix.'s_identity_number'])->first(); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | if (is_null($guardian)) { |
| 337 | 337 | $guardian = self::create([ |
| 338 | 338 | 'username' => str_replace('-', '', $openemisNo), |
| 339 | 339 | 'openemis_no' => $openemisNo, |
| 340 | - 'first_name' => $row[$prefix . 's_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
|
| 341 | - 'last_name' => genNameWithInitials($row[$prefix . 's_full_name']), |
|
| 340 | + 'first_name' => $row[$prefix.'s_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
|
| 341 | + 'last_name' => genNameWithInitials($row[$prefix.'s_full_name']), |
|
| 342 | 342 | 'gender_id' => 1, |
| 343 | - 'date_of_birth' => $row[$prefix . 's_date_of_birth_yyyy_mm_dd'], |
|
| 344 | - 'address' => $row[$prefix . 's_address'], |
|
| 343 | + 'date_of_birth' => $row[$prefix.'s_date_of_birth_yyyy_mm_dd'], |
|
| 344 | + 'address' => $row[$prefix.'s_address'], |
|
| 345 | 345 | 'address_area_id' => $AddressArea ? $AddressArea->id : null, |
| 346 | 346 | 'nationality_id' => $nationalityId, |
| 347 | 347 | 'identity_type_id' => $identityType, |
| 348 | - 'identity_number' => $row[$prefix . 's_identity_number'], |
|
| 348 | + 'identity_number' => $row[$prefix.'s_identity_number'], |
|
| 349 | 349 | 'is_guardian' => 1, |
| 350 | 350 | 'created_user_id' => $file['security_user_id'] |
| 351 | 351 | ]); |
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | $guardian['guardian_relation_id'] = 1; |
| 355 | - if (array_key_exists($prefix . 's_phone', $row)) { |
|
| 356 | - $father['contact'] = $row[$prefix . 's_phone']; |
|
| 355 | + if (array_key_exists($prefix.'s_phone', $row)) { |
|
| 356 | + $father['contact'] = $row[$prefix.'s_phone']; |
|
| 357 | 357 | User_contact::createOrUpdate($father, $file['security_user_id']); |
| 358 | 358 | } |
| 359 | - } else { |
|
| 360 | - Security_user::where('id', $guardian->id)->update(['address_area_id' => $AddressArea ? $AddressArea->id : null,]); |
|
| 359 | + }else { |
|
| 360 | + Security_user::where('id', $guardian->id)->update(['address_area_id' => $AddressArea ? $AddressArea->id : null, ]); |
|
| 361 | 361 | } |
| 362 | 362 | return $guardian; |
| 363 | - } catch (\Exception $e) { |
|
| 363 | + }catch (\Exception $e) { |
|
| 364 | 364 | Log::error($e->getMessage(), [$e]); |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -72,18 +72,18 @@ |
||
| 72 | 72 | 'institution_id' => $admissionInfo['instituion']->id, |
| 73 | 73 | 'academic_period_id' => $admissionInfo['academic_period']->id, |
| 74 | 74 | 'education_grade_id' => $admissionInfo['education_grade']->id, |
| 75 | - 'institution_class_id' => (($admissionInfo['instituion_class'] != []) && (count($admissionInfo['instituion_class'])==1)) ? $admissionInfo['instituion_class']['id'] : null, |
|
| 75 | + 'institution_class_id' => (($admissionInfo['instituion_class'] != []) && (count($admissionInfo['instituion_class']) == 1)) ? $admissionInfo['instituion_class']['id'] : null, |
|
| 76 | 76 | 'comment' => 'Imported From Examination Data', |
| 77 | 77 | 'updated_from' => 'doe', |
| 78 | 78 | 'created_user_id' => 1 |
| 79 | 79 | ]; |
| 80 | 80 | self::create($data); |
| 81 | - } catch (\Throwable $th) { |
|
| 81 | + }catch (\Throwable $th) { |
|
| 82 | 82 | Log::error($th); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public static function createAdmission($studentId,$row,$params,$file){ |
|
| 86 | + public static function createAdmission($studentId, $row, $params, $file) { |
|
| 87 | 87 | self::create([ |
| 88 | 88 | 'start_date' => $row['start_date_yyyy_mm_dd'], |
| 89 | 89 | 'start_year' => $row['start_date_yyyy_mm_dd']->format('Y'), |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class Security_group extends Model { |
|
| 7 | +class Security_group extends Model { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * The database table used by the model. |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | protected $dates = ['modified', 'created', 'created', 'created', 'modified', 'created']; |
| 43 | 43 | |
| 44 | - public function security_users(){ |
|
| 45 | - return $this->belongsTo('App\Models\Security_group_user','security_group_id'); |
|
| 44 | + public function security_users() { |
|
| 45 | + return $this->belongsTo('App\Models\Security_group_user', 'security_group_id'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - public function security_group_institution(){ |
|
| 50 | - return $this->hasMany('App\Models\Security_group_institution','security_group_id'); |
|
| 49 | + public function security_group_institution() { |
|
| 50 | + return $this->hasMany('App\Models\Security_group_institution', 'security_group_id'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | \ No newline at end of file |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public static function boot() |
| 72 | 72 | { |
| 73 | 73 | parent::boot(); |
| 74 | - self::creating(function ($model) { |
|
| 74 | + self::creating(function($model) { |
|
| 75 | 75 | $model->id = (string) Uuid::generate(4); |
| 76 | 76 | $model->created = now(); |
| 77 | 77 | }); |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | 'institution_students.admission_id' |
| 130 | 130 | ) |
| 131 | 131 | ->where('institution_students.institution_id', $institutionGrade['institution_id']) |
| 132 | - ->where('institution_students.student_status_id',1) |
|
| 132 | + ->where('institution_students.student_status_id', 1) |
|
| 133 | 133 | ->where('institution_students.education_grade_id', $institutionGrade['education_grade_id']) |
| 134 | - ->where('institution_students.deleted_at',null) |
|
| 134 | + ->where('institution_students.deleted_at', null) |
|
| 135 | 135 | ->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray(); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public static function createExaminationData($student, $admissionInfo) |
| 146 | 146 | { |
| 147 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 147 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 148 | 148 | try { |
| 149 | 149 | self::create([ |
| 150 | 150 | 'id' => (string) Uuid::generate(4), |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | 'created' => now(), |
| 170 | 170 | 'created_user_id' => 1 |
| 171 | 171 | ]); |
| 172 | - } catch (\Throwable $th) { |
|
| 172 | + }catch (\Throwable $th) { |
|
| 173 | 173 | Log::error($th); |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public static function updateExaminationData($student, $admissionInfo) |
| 185 | 185 | { |
| 186 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 186 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 187 | 187 | try { |
| 188 | 188 | self::where([ |
| 189 | 189 | 'student_id' => $student['student_id'], |
@@ -204,56 +204,56 @@ discard block |
||
| 204 | 204 | 'modified_user_id' => 1 |
| 205 | 205 | ] |
| 206 | 206 | ); |
| 207 | - } catch (\Throwable $th) { |
|
| 207 | + }catch (\Throwable $th) { |
|
| 208 | 208 | Log::error($th); |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - public static function updateStudentArea(array $student){ |
|
| 213 | - $father = Student_guardian::where('student_id',$student['student_id']) |
|
| 214 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
| 215 | - ->where('guardian_relation_id',1) |
|
| 212 | + public static function updateStudentArea(array $student) { |
|
| 213 | + $father = Student_guardian::where('student_id', $student['student_id']) |
|
| 214 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
| 215 | + ->where('guardian_relation_id', 1) |
|
| 216 | 216 | ->get()->first(); |
| 217 | 217 | |
| 218 | - $mother = Student_guardian::where('student_id',$student['student_id']) |
|
| 219 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
| 220 | - ->where('guardian_relation_id',2) |
|
| 218 | + $mother = Student_guardian::where('student_id', $student['student_id']) |
|
| 219 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
| 220 | + ->where('guardian_relation_id', 2) |
|
| 221 | 221 | ->get()->first(); |
| 222 | 222 | |
| 223 | - $guardian = Student_guardian::where('student_id',$student['student_id']) |
|
| 224 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
| 225 | - ->where('guardian_relation_id',3) |
|
| 223 | + $guardian = Student_guardian::where('student_id', $student['student_id']) |
|
| 224 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
| 225 | + ->where('guardian_relation_id', 3) |
|
| 226 | 226 | ->get()->first(); |
| 227 | 227 | |
| 228 | - if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
|
| 229 | - Security_user::where('id',$student['student_id']) |
|
| 228 | + if (!is_null($father) && is_null($mother) && is_null($guardian)) { |
|
| 229 | + Security_user::where('id', $student['student_id']) |
|
| 230 | 230 | ->update(['address_area_id' => $father->address_area_id]); |
| 231 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
| 232 | - Security_user::where('id',$student['student_id']) |
|
| 231 | + }elseif (!is_null($mother) && (is_null($father) && is_null($guardian))) { |
|
| 232 | + Security_user::where('id', $student['student_id']) |
|
| 233 | 233 | ->update(['address_area_id' => $mother->address_area_id]); |
| 234 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
| 235 | - Security_user::where('id',$student['student_id']) |
|
| 234 | + }elseif (!is_null($guardian) && is_null($father) && is_null($mother)) { |
|
| 235 | + Security_user::where('id', $student['student_id']) |
|
| 236 | 236 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 237 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
| 237 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) { |
|
| 238 | 238 | // dd($father->address_area_id,$mother->address_area_id,$student['student_id']); |
| 239 | - $d = Security_user::where('id',$student['student_id']) |
|
| 239 | + $d = Security_user::where('id', $student['student_id']) |
|
| 240 | 240 | ->update(['address_area_id' => $mother->address_area_id]); |
| 241 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
| 242 | - Security_user::where('id',$student['student_id']) |
|
| 241 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) { |
|
| 242 | + Security_user::where('id', $student['student_id']) |
|
| 243 | 243 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 244 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
| 245 | - Security_user::where('id',$student['student_id']) |
|
| 244 | + }elseif (!is_null($father) && $father->address == $student['address']) { |
|
| 245 | + Security_user::where('id', $student['student_id']) |
|
| 246 | 246 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 247 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
| 248 | - Security_user::where('id',$student['student_id']) |
|
| 247 | + }elseif (!is_null($mother) && $mother->address == $student['address']) { |
|
| 248 | + Security_user::where('id', $student['student_id']) |
|
| 249 | 249 | ->update(['address_area_id' => $mother->address_area_id]); |
| 250 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
| 251 | - Security_user::where('id',$student['student_id']) |
|
| 250 | + }elseif (!is_null($guardian) && $guardian->address == $student['address']) { |
|
| 251 | + Security_user::where('id', $student['student_id']) |
|
| 252 | 252 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - public static function createOrUpdate($studentId,$row,$params,$file){ |
|
| 256 | + public static function createOrUpdate($studentId, $row, $params, $file) { |
|
| 257 | 257 | self::create([ |
| 258 | 258 | 'student_status_id' => 1, |
| 259 | 259 | 'student_id' => $studentId, |