@@ -14,7 +14,7 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | protected function redirectTo($request) |
| 16 | 16 | { |
| 17 | - if (! $request->expectsJson()) { |
|
| 17 | + if (!$request->expectsJson()) { |
|
| 18 | 18 | return route('login'); |
| 19 | 19 | } |
| 20 | 20 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param Request $request |
| 35 | 35 | * @return \Illuminate\Http\JsonResponse |
| 36 | 36 | */ |
| 37 | - public function upload(Request $request){ |
|
| 37 | + public function upload(Request $request) { |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $institution = auth()->user()->permissions->isEmpty() ? auth()->user()->principal[0]->institution_group[0]->institution->code : auth()->user()->permissions[0]->institution_staff->institution->code; |
| 77 | 77 | |
| 78 | 78 | |
| 79 | - $fileName = time().'_'.$institution.'_'.str_replace(' ','_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
| 79 | + $fileName = time().'_'.$institution.'_'.str_replace(' ', '_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
| 80 | 80 | Storage::disk('local')->putFileAs( |
| 81 | 81 | 'sis-bulk-data-files/', |
| 82 | 82 | $uploadFile, |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | $upload = new Upload; |
| 87 | - $upload->fileName =$fileName; |
|
| 87 | + $upload->fileName = $fileName; |
|
| 88 | 88 | $upload->model = 'Student'; |
| 89 | 89 | $upload->node = 'None'; |
| 90 | 90 | $upload->institution_class_id = $class->id; |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | return redirect('/')->withSuccess('The file is uploaded, we will process and let you know by your email'); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function updateQueueWithUnprocessedFiles($id, $action){ |
|
| 99 | - if($action == 100){ |
|
| 98 | + public function updateQueueWithUnprocessedFiles($id, $action) { |
|
| 99 | + if ($action == 100) { |
|
| 100 | 100 | DB::table('uploads') |
| 101 | 101 | ->where('id', $id) |
| 102 | 102 | ->update(['is_processed' => 0]); |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
| 111 | - public function downloadTemplate(){ |
|
| 111 | + public function downloadTemplate() { |
|
| 112 | 112 | $filename = 'censusNo_className_sis_students_bulk_upload'; |
| 113 | 113 | $version = '2007_V1.7_20200510.xlsx'; |
| 114 | - $file_path = storage_path() .'/app/public/'. $filename.'_'.$version;; |
|
| 114 | + $file_path = storage_path().'/app/public/'.$filename.'_'.$version; ; |
|
| 115 | 115 | if (file_exists($file_path)) |
| 116 | 116 | { |
| 117 | 117 | return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ |
| 118 | - 'Content-Length: '. filesize($file_path) |
|
| 118 | + 'Content-Length: '.filesize($file_path) |
|
| 119 | 119 | ]); |
| 120 | 120 | } |
| 121 | 121 | else |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | * @param $filename |
| 130 | 130 | * @return Processed excel file with error |
| 131 | 131 | */ |
| 132 | - public function downloadErrorFile($filename){ |
|
| 132 | + public function downloadErrorFile($filename) { |
|
| 133 | 133 | |
| 134 | - $file_path = storage_path().'/app/sis-bulk-data-files/processed/'. $filename; |
|
| 134 | + $file_path = storage_path().'/app/sis-bulk-data-files/processed/'.$filename; |
|
| 135 | 135 | if (file_exists($file_path)) |
| 136 | 136 | { |
| 137 | 137 | return Response::download($file_path, $filename, [ |
| 138 | - 'Content-Length: '. filesize($file_path) |
|
| 138 | + 'Content-Length: '.filesize($file_path) |
|
| 139 | 139 | ]); |
| 140 | 140 | } |
| 141 | 141 | else |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
| 148 | - public function downloadFile($filename){ |
|
| 149 | - $file_path = storage_path().'/app/sis-bulk-data-files/'. $filename; |
|
| 148 | + public function downloadFile($filename) { |
|
| 149 | + $file_path = storage_path().'/app/sis-bulk-data-files/'.$filename; |
|
| 150 | 150 | if (file_exists($file_path)) |
| 151 | 151 | { |
| 152 | 152 | return Response::download($file_path, $filename, [ |
| 153 | - 'Content-Length: '. filesize($file_path) |
|
| 153 | + 'Content-Length: '.filesize($file_path) |
|
| 154 | 154 | ]); |
| 155 | 155 | } |
| 156 | 156 | else |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | DB::table('uploads') |
| 101 | 101 | ->where('id', $id) |
| 102 | 102 | ->update(['is_processed' => 0]); |
| 103 | - }elseif ($action == 200) { |
|
| 103 | + } elseif ($action == 200) { |
|
| 104 | 104 | DB::table('uploads') |
| 105 | 105 | ->where('id', $id) |
| 106 | 106 | ->update(['is_processed' => 4]); |
@@ -117,8 +117,7 @@ discard block |
||
| 117 | 117 | return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ |
| 118 | 118 | 'Content-Length: '. filesize($file_path) |
| 119 | 119 | ]); |
| 120 | - } |
|
| 121 | - else |
|
| 120 | + } else |
|
| 122 | 121 | { |
| 123 | 122 | return View::make('errors.404'); |
| 124 | 123 | } |
@@ -137,8 +136,7 @@ discard block |
||
| 137 | 136 | return Response::download($file_path, $filename, [ |
| 138 | 137 | 'Content-Length: '. filesize($file_path) |
| 139 | 138 | ]); |
| 140 | - } |
|
| 141 | - else |
|
| 139 | + } else |
|
| 142 | 140 | { |
| 143 | 141 | abort(404, 'We did not found an error file.'); |
| 144 | 142 | } |
@@ -152,8 +150,7 @@ discard block |
||
| 152 | 150 | return Response::download($file_path, $filename, [ |
| 153 | 151 | 'Content-Length: '. filesize($file_path) |
| 154 | 152 | ]); |
| 155 | - } |
|
| 156 | - else |
|
| 153 | + } else |
|
| 157 | 154 | { |
| 158 | 155 | |
| 159 | 156 | abort(404, 'We did not found an error file.'); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | - public function findUsername(){ |
|
| 57 | + public function findUsername() { |
|
| 58 | 58 | $login = request()->input('username'); |
| 59 | 59 | |
| 60 | - $fieldType = filter_var($login,FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
|
| 60 | + $fieldType = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
|
| 61 | 61 | |
| 62 | 62 | request()->merge([$fieldType => $login]); |
| 63 | 63 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @return string |
| 69 | 69 | */ |
| 70 | - public function username(){ |
|
| 70 | + public function username() { |
|
| 71 | 71 | return $this->username; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | trait HasPermissionsTrait |
| 9 | 9 | { |
| 10 | - public function roles(){ |
|
| 11 | - return $this->belongsToMany(Security_group_user::class,'security_group_users'); |
|
| 10 | + public function roles() { |
|
| 11 | + return $this->belongsToMany(Security_group_user::class, 'security_group_users'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - public function hasRole( ... $roles ) { |
|
| 15 | + public function hasRole(... $roles) { |
|
| 16 | 16 | foreach ($roles as $role) { |
| 17 | 17 | if ($this->roles->contains('code', $role)) { |
| 18 | 18 | return true; |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
| 85 | 85 | $higestRow = 0; |
| 86 | 86 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
| 87 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
| 87 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
| 88 | 88 | if (isEmptyRow(reset($rowData))) { |
| 89 | 89 | continue; |
| 90 | - } else { |
|
| 90 | + }else { |
|
| 91 | 91 | $higestRow += 1; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function validateColumns($column) { |
| 98 | 98 | $columns = Config::get('excel.columns'); |
| 99 | - if ( ($column !== "") && (!in_array($column,$columns))) { |
|
| 99 | + if (($column !== "") && (!in_array($column, $columns))) { |
|
| 100 | 100 | |
| 101 | 101 | $this->isValidSheet = false; |
| 102 | 102 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
| 112 | 112 | $higestRow = 1; |
| 113 | 113 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
| 114 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
| 114 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
| 115 | 115 | if (isEmptyRow(reset($rowData))) { |
| 116 | 116 | continue; |
| 117 | - } else { |
|
| 117 | + }else { |
|
| 118 | 118 | $higestRow += 1; |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | if ($higestRow == 0) { |
| 122 | 122 | exit; |
| 123 | - } else { |
|
| 123 | + }else { |
|
| 124 | 124 | return $higestRow; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -135,22 +135,22 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | - protected function formateDate($row,$column,$format = 'Y-m-d'){ |
|
| 138 | + protected function formateDate($row, $column, $format = 'Y-m-d') { |
|
| 139 | 139 | try { |
| 140 | - if(!empty($row[$column]) && ($row[$column] !== null)){ |
|
| 141 | - switch (gettype($row[$column])){ |
|
| 140 | + if (!empty($row[$column]) && ($row[$column] !== null)) { |
|
| 141 | + switch (gettype($row[$column])) { |
|
| 142 | 142 | case 'string': |
| 143 | 143 | $row[$column] = preg_replace('/[^A-Za-z0-9\-]/', '-', $row[$column]); |
| 144 | 144 | $row[$column] = date($format, strtotime($row[$column])); //date($row[$column]); |
| 145 | - $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
| 145 | + $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
| 146 | 146 | break; |
| 147 | 147 | case 'double'; |
| 148 | - $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
| 148 | + $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
| 149 | 149 | break; |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | return $row; |
| 153 | - }catch (Exception $e){ |
|
| 153 | + }catch (Exception $e) { |
|
| 154 | 154 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 155 | 155 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
| 156 | 156 | $failures = [0 => $failure]; |
@@ -160,32 +160,32 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
| 163 | - protected function mapFields($row){ |
|
| 163 | + protected function mapFields($row) { |
|
| 164 | 164 | |
| 165 | 165 | $keys = array_keys($row); |
| 166 | 166 | |
| 167 | - array_walk($keys,array($this,'validateColumns')); |
|
| 168 | - $row = $this->formateDate($row,'date_of_birth_yyyy_mm_dd'); |
|
| 169 | - $row = $this->formateDate($row,'bmi_date_yyyy_mm_dd'); |
|
| 170 | - $row = $this->formateDate($row,'start_date_yyyy_mm_dd'); |
|
| 171 | - $row = $this->formateDate($row,'fathers_date_of_birth_yyyy_mm_dd'); |
|
| 172 | - $row = $this->formateDate($row,'mothers_date_of_birth_yyyy_mm_dd'); |
|
| 173 | - $row = $this->formateDate($row,'guardians_date_of_birth_yyyy_mm_dd'); |
|
| 167 | + array_walk($keys, array($this, 'validateColumns')); |
|
| 168 | + $row = $this->formateDate($row, 'date_of_birth_yyyy_mm_dd'); |
|
| 169 | + $row = $this->formateDate($row, 'bmi_date_yyyy_mm_dd'); |
|
| 170 | + $row = $this->formateDate($row, 'start_date_yyyy_mm_dd'); |
|
| 171 | + $row = $this->formateDate($row, 'fathers_date_of_birth_yyyy_mm_dd'); |
|
| 172 | + $row = $this->formateDate($row, 'mothers_date_of_birth_yyyy_mm_dd'); |
|
| 173 | + $row = $this->formateDate($row, 'guardians_date_of_birth_yyyy_mm_dd'); |
|
| 174 | 174 | $columns = Config::get('excel.columns'); |
| 175 | - if(!$this->template) { |
|
| 175 | + if (!$this->template) { |
|
| 176 | 176 | array_walk($columns, array($this, 'checkKeys'), $row); |
| 177 | 177 | $this->template = true; |
| 178 | 178 | } |
| 179 | - $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
| 179 | + $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
| 180 | 180 | if ($row['identity_type'] == 'BC' && (!empty($row['birth_divisional_secretariat'])) && ($row['identity_number'] !== null) && $row['date_of_birth_yyyy_mm_dd'] !== null) { |
| 181 | - $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
| 181 | + $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
| 182 | 182 | // dd(($row['date_of_birth_yyyy_mm_dd'])); |
| 183 | - $BirthDivision = Area_administrative::where('name', 'like', '%' . $row['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5)->first(); |
|
| 183 | + $BirthDivision = Area_administrative::where('name', 'like', '%'.$row['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5)->first(); |
|
| 184 | 184 | if ($BirthDivision !== null) { |
| 185 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%') |
|
| 185 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%') |
|
| 186 | 186 | ->where('parent_id', '=', $BirthDivision->id)->first(); |
| 187 | 187 | if ($BirthArea !== null) { |
| 188 | - $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"); |
|
| 188 | + $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"); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | return $row; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - protected function checkKeys($key,$count,$row){ |
|
| 197 | - if(array_key_exists($key,$row)){ |
|
| 196 | + protected function checkKeys($key, $count, $row) { |
|
| 197 | + if (array_key_exists($key, $row)) { |
|
| 198 | 198 | return true; |
| 199 | - }else{ |
|
| 199 | + }else { |
|
| 200 | 200 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 201 | - $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]); |
|
| 201 | + $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]); |
|
| 202 | 202 | $failures = [0 => $failure]; |
| 203 | 203 | new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 204 | 204 | }; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | public function map($row): array { |
| 218 | 218 | try { |
| 219 | 219 | $row = $this->mapFields($row); |
| 220 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 220 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 221 | 221 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 222 | 222 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
| 223 | 223 | $failures = [0 => $failure]; |
@@ -239,19 +239,19 @@ discard block |
||
| 239 | 239 | if ($exceededStudents == true) { |
| 240 | 240 | try { |
| 241 | 241 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 242 | - $failure = new Failure(3, 'remark', [3 => 'Class student count exceeded! Max number of students is' . $institutionClass->no_of_students], [null]); |
|
| 242 | + $failure = new Failure(3, 'remark', [3 => 'Class student count exceeded! Max number of students is'.$institutionClass->no_of_students], [null]); |
|
| 243 | 243 | $failures = [0 => $failure]; |
| 244 | 244 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 245 | 245 | Log::info('email-sent', [$this->file]); |
| 246 | - } catch (Exception $e) { |
|
| 246 | + }catch (Exception $e) { |
|
| 247 | 247 | Log::info('email-sending-failed', [$e]); |
| 248 | 248 | } |
| 249 | - } else { |
|
| 249 | + }else { |
|
| 250 | 250 | return true; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - public function getNode(){ |
|
| 254 | + public function getNode() { |
|
| 255 | 255 | return $this->file['node']; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | /** |
| 306 | 306 | * |
| 307 | 307 | */ |
| 308 | - protected function setStudentSubjects($subject){ |
|
| 308 | + protected function setStudentSubjects($subject) { |
|
| 309 | 309 | return [ |
| 310 | 310 | 'id' => (string) Uuid::generate(4), |
| 311 | 311 | 'student_id' => $this->student->student_id, |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | ]; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - protected function insertSubject($subject){ |
|
| 325 | - if(!Institution_subject_student::isDuplicated($subject)){ |
|
| 324 | + protected function insertSubject($subject) { |
|
| 325 | + if (!Institution_subject_student::isDuplicated($subject)) { |
|
| 326 | 326 | Institution_subject_student::updateOrInsert($subject); |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | return $row; |
| 153 | - }catch (Exception $e){ |
|
| 153 | + } catch (Exception $e){ |
|
| 154 | 154 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 155 | 155 | $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); |
| 156 | 156 | $failures = [0 => $failure]; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | protected function checkKeys($key,$count,$row){ |
| 197 | 197 | if(array_key_exists($key,$row)){ |
| 198 | 198 | return true; |
| 199 | - }else{ |
|
| 199 | + } else{ |
|
| 200 | 200 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 201 | 201 | $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]); |
| 202 | 202 | $failures = [0 => $failure]; |
@@ -423,8 +423,9 @@ |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | protected function insertSubject($subject){ |
| 426 | - if(!Institution_subject_student::isDuplicated($subject)) |
|
| 427 | - Institution_subject_student::updateOrInsert($subject); |
|
| 426 | + if(!Institution_subject_student::isDuplicated($subject)) { |
|
| 427 | + Institution_subject_student::updateOrInsert($subject); |
|
| 428 | + } |
|
| 428 | 429 | } |
| 429 | 430 | |
| 430 | 431 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | use Maatwebsite\Excel\Concerns\WithMultipleSheets; |
| 55 | 55 | use Maatwebsite\Excel\Concerns\RegistersEventListeners; |
| 56 | 56 | |
| 57 | -class StudentUpdate extends Import implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation , SkipsOnFailure , SkipsOnError{ |
|
| 57 | +class StudentUpdate extends Import implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation, SkipsOnFailure, SkipsOnError{ |
|
| 58 | 58 | |
| 59 | 59 | use Importable, |
| 60 | 60 | RegistersEventListeners, |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $worksheet = $event->getSheet(); |
| 80 | 80 | $this->highestRow = $worksheet->getHighestDataRow('B'); |
| 81 | 81 | }, |
| 82 | - BeforeImport::class => function (BeforeImport $event) { |
|
| 82 | + BeforeImport::class => function(BeforeImport $event) { |
|
| 83 | 83 | $event->getReader()->getDelegate()->setActiveSheetIndex(2); |
| 84 | 84 | $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('B')); |
| 85 | 85 | if ($this->highestRow < 3) { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $mandatorySubject = Institution_class_subject::getMandetorySubjects($this->file['institution_class_id']); |
| 109 | 109 | $subjects = getMatchingKeys($row); |
| 110 | 110 | $genderId = null; |
| 111 | - if($row['gender_mf'] !== null){ |
|
| 111 | + if ($row['gender_mf'] !== null) { |
|
| 112 | 112 | $genderId = $row['gender_mf'] == 'M' ? 1 : 2; |
| 113 | 113 | } |
| 114 | 114 | switch ($row['gender_mf']) { |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | break; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
| 124 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
| 125 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
| 123 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
| 124 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
| 125 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
| 126 | 126 | $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first(); |
| 127 | 127 | |
| 128 | 128 | |
@@ -191,17 +191,17 @@ discard block |
||
| 191 | 191 | if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) { |
| 192 | 192 | |
| 193 | 193 | // convert Meeter to CM |
| 194 | - $hight = $row['bmi_height'] / 100; |
|
| 194 | + $hight = $row['bmi_height']/100; |
|
| 195 | 195 | |
| 196 | 196 | //calculate BMI |
| 197 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
| 197 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
| 198 | 198 | |
| 199 | 199 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
| 200 | - $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id ) |
|
| 201 | - ->where('security_user_id','=',$student->student_id)->count(); |
|
| 200 | + $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id) |
|
| 201 | + ->where('security_user_id', '=', $student->student_id)->count(); |
|
| 202 | 202 | |
| 203 | 203 | \Log::debug('User_body_mass'); |
| 204 | - if(!($count > 0)){ |
|
| 204 | + if (!($count > 0)) { |
|
| 205 | 205 | User_body_mass::create([ |
| 206 | 206 | 'height' => $row['bmi_height'], |
| 207 | 207 | 'weight' => $row['bmi_weight'], |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 218 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); |
|
| 219 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); |
|
| 220 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); |
|
| 221 | - $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
| 218 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); |
|
| 219 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); |
|
| 220 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); |
|
| 221 | + $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
| 222 | 222 | |
| 223 | 223 | $identityType = ($identityType !== null) ? $identityType->id : null; |
| 224 | 224 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | if ($father === null) { |
| 234 | 234 | $data = [ |
| 235 | - 'username' => str_replace('-','',$openemisFather), |
|
| 235 | + 'username' => str_replace('-', '', $openemisFather), |
|
| 236 | 236 | 'openemis_no' => $openemisFather, |
| 237 | 237 | 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
| 238 | 238 | 'last_name' => genNameWithInitials($row['fathers_full_name']), |
@@ -251,25 +251,25 @@ discard block |
||
| 251 | 251 | $father['guardian_relation_id'] = 1; |
| 252 | 252 | if (array_key_exists('fathers_phone', $row)) { |
| 253 | 253 | $father['contact'] = $row['fathers_phone']; |
| 254 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
| 254 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
| 255 | 255 | } |
| 256 | 256 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
| 257 | - } else { |
|
| 257 | + }else { |
|
| 258 | 258 | Security_user::where('id', '=', $father->id) |
| 259 | 259 | ->update(['is_guardian' => 1]); |
| 260 | 260 | $father['guardian_relation_id'] = 1; |
| 261 | 261 | if (array_key_exists('fathers_phone', $row)) { |
| 262 | 262 | $father['contact'] = $row['fathers_phone']; |
| 263 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
| 263 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
| 264 | 264 | } |
| 265 | 265 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 270 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); |
|
| 271 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); |
|
| 272 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); |
|
| 270 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); |
|
| 271 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); |
|
| 272 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); |
|
| 273 | 273 | $openemisMother = $this->uniqueUid::getUniqueAlphanumeric(); |
| 274 | 274 | |
| 275 | 275 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | if ($mother === null) { |
| 286 | 286 | $mother = Security_user::create([ |
| 287 | - 'username' => str_replace('-','',$openemisMother), |
|
| 287 | + 'username' => str_replace('-', '', $openemisMother), |
|
| 288 | 288 | 'openemis_no' => $openemisMother, |
| 289 | 289 | 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
| 290 | 290 | 'last_name' => genNameWithInitials($row['mothers_full_name']), |
@@ -302,16 +302,16 @@ discard block |
||
| 302 | 302 | $mother['guardian_relation_id'] = 2; |
| 303 | 303 | if (array_key_exists('mothers_phone', $row)) { |
| 304 | 304 | $mother['contact'] = $row['mothers_phone']; |
| 305 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
| 305 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
| 306 | 306 | } |
| 307 | 307 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
| 308 | - } else { |
|
| 308 | + }else { |
|
| 309 | 309 | Security_user::where('id', '=', $mother->id) |
| 310 | 310 | ->update(['is_guardian' => 1]); |
| 311 | 311 | $mother['guardian_relation_id'] = 2; |
| 312 | 312 | if (array_key_exists('mothers_phone', $row)) { |
| 313 | 313 | $mother['contact'] = $row['mothers_phone']; |
| 314 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
| 314 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
| 315 | 315 | } |
| 316 | 316 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
| 317 | 317 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { |
| 322 | 322 | $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; |
| 323 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); |
|
| 324 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); |
|
| 325 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); |
|
| 323 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); |
|
| 324 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); |
|
| 325 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); |
|
| 326 | 326 | $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric(); |
| 327 | 327 | |
| 328 | 328 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | if ($guardian === null) { |
| 339 | 339 | $guardian = Security_user::create([ |
| 340 | - 'username' => str_replace('-','',$openemisGuardian), |
|
| 340 | + 'username' => str_replace('-', '', $openemisGuardian), |
|
| 341 | 341 | 'openemis_no' => $openemisGuardian, |
| 342 | 342 | 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
| 343 | 343 | 'last_name' => genNameWithInitials($row['guardians_full_name']), |
@@ -356,22 +356,22 @@ discard block |
||
| 356 | 356 | $guardian['guardian_relation_id'] = 3; |
| 357 | 357 | if (array_key_exists('guardians_phone', $row)) { |
| 358 | 358 | $guardian['contact'] = $row['guardians_phone']; |
| 359 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
| 359 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
| 360 | 360 | } |
| 361 | 361 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
| 362 | - } else { |
|
| 362 | + }else { |
|
| 363 | 363 | Security_user::where('id', '=', $guardian->id) |
| 364 | 364 | ->update(['is_guardian' => 1]); |
| 365 | 365 | $guardian['guardian_relation_id'] = 3; |
| 366 | 366 | if (array_key_exists('guardians_phone', $row)) { |
| 367 | 367 | $guardian['contact'] = $row['guardians_phone']; |
| 368 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
| 368 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
| 369 | 369 | } |
| 370 | 370 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
| 374 | + $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
| 375 | 375 | |
| 376 | 376 | $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject); |
| 377 | 377 | // $stundetSubjects = $this->getStudentSubjects($student); |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | if (!empty($allSubjects)) { |
| 381 | 381 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); |
| 382 | 382 | $this->student = $student; |
| 383 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); |
|
| 383 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); |
|
| 384 | 384 | // $allSubjects = array_unique($allSubjects,SORT_REGULAR); |
| 385 | 385 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
| 386 | - array_walk($allSubjects,array($this,'insertSubject')); |
|
| 386 | + array_walk($allSubjects, array($this, 'insertSubject')); |
|
| 387 | 387 | // Institution_subject_student::insert((array) $allSubjects); |
| 388 | 388 | // array_walk($allSubjects, array($this, 'updateSubjectCount')); |
| 389 | 389 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | if ($totalStudents['total'] > $institutionClass->no_of_students) { |
| 396 | 396 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 397 | - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); |
|
| 397 | + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); |
|
| 398 | 398 | $failures = [0 => $failure]; |
| 399 | 399 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
| 400 | 400 | Log::info('email-sent', [$this->file]); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | 'total_male_students' => $totalStudents['total_male_students'], |
| 407 | 407 | 'total_female_students' => $totalStudents['total_female_students']]); |
| 408 | 408 | } |
| 409 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 409 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
| 410 | 410 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
| 411 | 411 | $failures = $e->failures(); |
| 412 | 412 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -420,8 +420,8 @@ discard block |
||
| 420 | 420 | ->where('institution_class_id', '=', $student->institution_class_id)->get()->toArray(); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - protected function insertSubject($subject){ |
|
| 424 | - if(!Institution_subject_student::isDuplicated($subject)) |
|
| 423 | + protected function insertSubject($subject) { |
|
| 424 | + if (!Institution_subject_student::isDuplicated($subject)) |
|
| 425 | 425 | Institution_subject_student::updateOrInsert($subject); |
| 426 | 426 | } |
| 427 | 427 | |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | '*.admission_no' => 'nullable|max:12|min:4', |
| 451 | 451 | '*.start_date_yyyy_mm_dd' => 'nullable|date', |
| 452 | 452 | '*.special_need_type' => 'nullable', |
| 453 | - '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able',//|exists:special_need_difficulties,name |
|
| 453 | + '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able', //|exists:special_need_difficulties,name |
|
| 454 | 454 | '*.fathers_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u', |
| 455 | 455 | '*.fathers_date_of_birth_yyyy_mm_dd' => 'nullable|required_with:*.fathers_full_name', |
| 456 | 456 | '*.fathers_address' => 'required_with:*.fathers_full_name', |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | // TODO: Implement registerEvents() method. |
| 41 | 41 | |
| 42 | 42 | return [ |
| 43 | - BeforeSheet::class => function(BeforeSheet $event){ |
|
| 43 | + BeforeSheet::class => function(BeforeSheet $event) { |
|
| 44 | 44 | $this->sheetNames[] = $event->getSheet()->getTitle(); |
| 45 | 45 | |
| 46 | 46 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function boot() |
| 29 | 29 | { |
| 30 | 30 | // |
| 31 | - if((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { |
|
| 31 | + if ((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { |
|
| 32 | 32 | URL::forceScheme('https'); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -56,43 +56,43 @@ discard block |
||
| 56 | 56 | if (empty($value)) { |
| 57 | 57 | return false; |
| 58 | 58 | } elseif ($gradeEntity !== null) { |
| 59 | - $admissionAge = (($gradeEntity->admission_age)*12)-1; |
|
| 59 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
| 60 | 60 | $to = $academicPeriod->start_date; |
| 61 | 61 | $diff_in_months = $to->diffInMonths($value); |
| 62 | 62 | $ageOfStudent = $diff_in_months; |
| 63 | 63 | $enrolmentMaximumAge = $admissionAge + 120; |
| 64 | 64 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
| 65 | - } else { |
|
| 65 | + }else { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | protected function validateBmi($attribute, $value, $parameters) |
| 71 | 71 | { |
| 72 | - $bmiGrades = ['G1','G4','G7','G10']; |
|
| 72 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
| 73 | 73 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
| 74 | - ->join('education_grades','institution_class_grades.education_grade_id','education_grades.id') |
|
| 74 | + ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
|
| 75 | 75 | ->first(); |
| 76 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
| 77 | - if(in_array($institutionGrade->code,$bmiGrades)){ |
|
| 78 | - if(!empty($value)){ |
|
| 79 | - if(($attribute == 'bmi_height') || ('bmi_weight')){ |
|
| 76 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
| 77 | + if (in_array($institutionGrade->code, $bmiGrades)) { |
|
| 78 | + if (!empty($value)) { |
|
| 79 | + if (($attribute == 'bmi_height') || ('bmi_weight')) { |
|
| 80 | 80 | $v = Validator::make([$attribute => $value], [ |
| 81 | 81 | $attribute => 'number|min:10|max:200' |
| 82 | 82 | ]); |
| 83 | - if($v->fails()) { |
|
| 84 | - $this->_custom_messages['bmi'] = $attribute.' is not a valid input'; |
|
| 83 | + if ($v->fails()) { |
|
| 84 | + $this->_custom_messages['bmi'] = $attribute.' is not a valid input'; |
|
| 85 | 85 | $this->_set_custom_stuff(); |
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | return true; |
| 89 | 89 | } |
| 90 | - }else{ |
|
| 91 | - $this->_custom_messages['bmi'] = $attribute.' is required for '. $educationGrade->name; |
|
| 90 | + }else { |
|
| 91 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
| 92 | 92 | $this->_set_custom_stuff(); |
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | - }else{ |
|
| 95 | + }else { |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -100,58 +100,58 @@ discard block |
||
| 100 | 100 | protected function validateBirthPlace($attribute, $value, $perameters, $validator) { |
| 101 | 101 | foreach ($validator->getData() as $data) { |
| 102 | 102 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
| 103 | - $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
| 104 | - if ($BirthDivision->count() > 0 ) { |
|
| 105 | - $BirthArea = Area_administrative::where('name', '=', '%'. $value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
| 103 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
| 104 | + if ($BirthDivision->count() > 0) { |
|
| 105 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
| 106 | 106 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
| 107 | - return $BirthArea > 0; |
|
| 107 | + return $BirthArea > 0; |
|
| 108 | 108 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
| 109 | 109 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
| 110 | 110 | $this->_set_custom_stuff(); |
| 111 | 111 | return false; |
| 112 | - } else { |
|
| 112 | + }else { |
|
| 113 | 113 | return true; |
| 114 | 114 | } |
| 115 | - } else { |
|
| 115 | + }else { |
|
| 116 | 116 | return true; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) { |
| 122 | - $student = Security_user::where('openemis_no', '=', $value); |
|
| 123 | - if($student->count() > 0){ |
|
| 122 | + $student = Security_user::where('openemis_no', '=', $value); |
|
| 123 | + if ($student->count() > 0) { |
|
| 124 | 124 | $student = $student->first()->toArray(); |
| 125 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id','=',$perameters[0])->count(); |
|
| 126 | - if($check == 1){ |
|
| 125 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
| 126 | + if ($check == 1) { |
|
| 127 | 127 | return true; |
| 128 | - }else{ |
|
| 128 | + }else { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | - }else{ |
|
| 131 | + }else { |
|
| 132 | 132 | return false; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | } |
| 136 | - protected function validateNic($attribute, $value, $perameters, $validator){ |
|
| 136 | + protected function validateNic($attribute, $value, $perameters, $validator) { |
|
| 137 | 137 | $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value); |
| 138 | - if(!$valid){ |
|
| 139 | - $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; |
|
| 138 | + if (!$valid) { |
|
| 139 | + $this->_custom_messages['nic'] = $attribute.' is not valid, Please check the NIC number'; |
|
| 140 | 140 | $this->_set_custom_stuff(); |
| 141 | 141 | return false; |
| 142 | - }else{ |
|
| 142 | + }else { |
|
| 143 | 143 | return true; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | protected function validateUserUnique($attribute, $value, $perameters, $validator) { |
| 148 | 148 | foreach ($validator->getData() as $data) { |
| 149 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 149 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 150 | 150 | if ($identityType !== null && ($value !== null)) { |
| 151 | 151 | if ($identityType->national_code === 'BC') { |
| 152 | - return $this->checkUnique($value, $data,$identityType); |
|
| 152 | + return $this->checkUnique($value, $data, $identityType); |
|
| 153 | 153 | } elseif ($identityType->national_code === 'NIC') { |
| 154 | - return $this->checkUnique($value, $data,$identityType); |
|
| 154 | + return $this->checkUnique($value, $data, $identityType); |
|
| 155 | 155 | } |
| 156 | 156 | } elseif (($value == null) || $value == "") { |
| 157 | 157 | return true; |
@@ -161,39 +161,39 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | protected function validateIsBc($attribute, $value, $perameters, $validator) { |
| 163 | 163 | foreach ($validator->getData() as $data) { |
| 164 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 164 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 165 | 165 | if (($identityType !== null) && ($identityType !== "")) { |
| 166 | 166 | if (($identityType->national_code) === 'BC') { |
| 167 | 167 | return (strlen((string) $data['identity_number']) < 7); |
| 168 | - } else { |
|
| 168 | + }else { |
|
| 169 | 169 | return true; |
| 170 | 170 | } |
| 171 | - } else { |
|
| 171 | + }else { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - protected function checkUnique($value, $data,$identityType) { |
|
| 177 | + protected function checkUnique($value, $data, $identityType) { |
|
| 178 | 178 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
| 179 | 179 | if ($isUnique->count() > 0) { |
| 180 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
| 180 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
| 181 | 181 | $this->_set_custom_stuff(); |
| 182 | 182 | return false; |
| 183 | - } else { |
|
| 183 | + }else { |
|
| 184 | 184 | return true; |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | protected function IsBc($data, $value) { |
| 189 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 189 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 190 | 190 | if ($identityType !== null) { |
| 191 | 191 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
| 192 | 192 | return false; |
| 193 | - } else { |
|
| 193 | + }else { |
|
| 194 | 194 | return true; |
| 195 | 195 | } |
| 196 | - } else { |
|
| 196 | + }else { |
|
| 197 | 197 | return true; |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | return true; |
| 89 | 89 | } |
| 90 | - }else{ |
|
| 90 | + } else{ |
|
| 91 | 91 | $this->_custom_messages['bmi'] = $attribute.' is required for '. $educationGrade->name; |
| 92 | 92 | $this->_set_custom_stuff(); |
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | - }else{ |
|
| 95 | + } else{ |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id','=',$perameters[0])->count(); |
| 126 | 126 | if($check == 1){ |
| 127 | 127 | return true; |
| 128 | - }else{ |
|
| 128 | + } else{ |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | - }else{ |
|
| 131 | + } else{ |
|
| 132 | 132 | return false; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; |
| 140 | 140 | $this->_set_custom_stuff(); |
| 141 | 141 | return false; |
| 142 | - }else{ |
|
| 142 | + } else{ |
|
| 143 | 143 | return true; |
| 144 | 144 | } |
| 145 | 145 | } |