Test Setup Failed
Push — master ( 9242ba...72885b )
by Mohamed
55:51 queued 48:01
created
app/Imports/Import.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
     {
231 231
         if (array_key_exists($key, $row)) {
232 232
             return true;
233
-        } else {
233
+        }else {
234 234
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
235
-            $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]);
235
+            $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 236
             $failures = [0 => $failure];
237 237
             new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
238 238
         };
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
         $exceededStudents = ($totalStudents + $this->limit()) > $institutionClass->no_of_students ? true : false;
268 268
         if ($exceededStudents == true) {
269 269
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
270
-            $failure = new Failure(3, 'remark', ['Class student count exceeded! Max number of students is' . $institutionClass->no_of_students], [null]);
270
+            $failure = new Failure(3, 'remark', ['Class student count exceeded! Max number of students is'.$institutionClass->no_of_students], [null]);
271 271
             $failures = [0 => $failure];
272 272
             throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
273 273
             Log::info('email-sent', [$this->file]);
274
-        } else {
274
+        }else {
275 275
             return true;
276 276
         }
277 277
     }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
     public function createOrUpdateGuardian($row, $student, $param)
334 334
     {
335
-        if (!empty($row[$param . 's_full_name']) && ($row[$param . 's_date_of_birth_yyyy_mm_dd'] !== null)) {
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)
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
     {
375 375
         $mandatorySubject = Institution_class_subject::getMandatorySubjects($this->file['institution_class_id']);
376 376
         $subjects = getMatchingKeys($row);
377
-        $optionalSubjects =  Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution);
377
+        $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution);
378 378
         $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject);
379 379
         if (!empty($allSubjects)) {
380 380
             $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id');
Please login to merge, or discard this patch.
app/Imports/UsersImport.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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([]);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
             if (!empty($institutionClass)) {
115 115
                 $row = $this->setGender($row);
116
-                $studentInfo = Security_user::createOrUpdateStudentProfile($row,'create',$this->file);  
116
+                $studentInfo = Security_user::createOrUpdateStudentProfile($row, 'create', $this->file);  
117 117
                 $academicPeriod = Academic_period::where('id', '=', $institutionClass->academic_period_id)->first();
118 118
                 $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass->id)->first();
119 119
                 $assignee_id = $institutionClass->staff_id ? $institutionClass->staff_id : $this->file['security_user_id'];
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
                     'institution_class' => $institutionClass
127 127
                 ];
128 128
 
129
-                Institution_student_admission::createAdmission($studentInfo->id,$row,$params,$this->file);
130
-                Institution_student::createOrUpdate($studentInfo->id,$row,$params,$this->file);
131
-                $student = Institution_class_student::createOrUpdate($studentInfo->id,$params,$this->file);
132
-                User_special_need::createOrUpdate($student->student_id,$row,$this->file);
133
-                User_body_mass::createOrUpdate($student->student_id,$row,$this->file);
129
+                Institution_student_admission::createAdmission($studentInfo->id, $row, $params, $this->file);
130
+                Institution_student::createOrUpdate($studentInfo->id, $row, $params, $this->file);
131
+                $student = Institution_class_student::createOrUpdate($studentInfo->id, $params, $this->file);
132
+                User_special_need::createOrUpdate($student->student_id, $row, $this->file);
133
+                User_body_mass::createOrUpdate($student->student_id, $row, $this->file);
134 134
 
135
-                $this->createOrUpdateGuardian($row,$student,'father');
136
-                $this->createOrUpdateGuardian($row,$student,'mother');
137
-                $this->createOrUpdateGuardian($row,$student,'guardian');
135
+                $this->createOrUpdateGuardian($row, $student, 'father');
136
+                $this->createOrUpdateGuardian($row, $student, 'mother');
137
+                $this->createOrUpdateGuardian($row, $student, 'guardian');
138 138
                 
139 139
                 $studentInfo['student_id'] = $studentInfo->id;
140 140
                 Institution_student::updateStudentArea($studentInfo->toArray());
141 141
 
142
-                $this->insertOrUpdateSubjects($row,$student,$institution);
142
+                $this->insertOrUpdateSubjects($row, $student, $institution);
143 143
 
144 144
                 $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']);
145 145
                 if ($totalStudents['total'] > $institutionClass->no_of_students) {
146 146
                     $error = \Illuminate\Validation\ValidationException::withMessages([]);
147
-                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]);
147
+                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]);
148 148
                     $failures = [0 => $failure];
149 149
                     throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
150 150
                     Log::info('email-sent', [$this->file]);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 $institutionClass = new Institution_class();
154 154
                 $institutionClass->updateClassCount($this->file);
155 155
             }
156
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
156
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
157 157
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
158 158
             $failures = $e->failures();
159 159
             throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             '*.full_name' => 'required|regex:/^[a-zA-Z .]*$/u|max:256',
169 169
             '*.preferred_name' => 'nullable|regex:/^[a-zA-Z .]*$/u|max:90',
170 170
             '*.gender_mf' => 'required|in:M,F',
171
-            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'],
171
+            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'],
172 172
             '*.address' => 'nullable',
173 173
             '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place',
174 174
             '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate',
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
             '*.identity_number' => 'nullable|identity:identity_type|required_with:*.identity_type',
178 178
             '*.education_grade' => 'required',
179 179
             '*.option_*' => 'nullable|exists:education_subjects,name',
180
-            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'],
181
-            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'],
180
+            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'],
181
+            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'],
182 182
             '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].'
183 183
             '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name',
184 184
             '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/',
Please login to merge, or discard this patch.
app/Models/Institution_student.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,55 +204,55 @@  discard block
 block discarded – undo
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)){
238
-            Security_user::where('id',$student['student_id'])
237
+        }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) {
238
+            Security_user::where('id', $student['student_id'])
239 239
             ->update(['address_area_id' => $mother->address_area_id]);
240
-        }elseif(!is_null($mother)  && !is_null($father) && ($father->address_area_id !==  $mother->address_area_id) && !is_null($guardian)){
241
-            Security_user::where('id',$student['student_id'])
240
+        }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) {
241
+            Security_user::where('id', $student['student_id'])
242 242
             ->update(['address_area_id' => $guardian->address_area_id]);
243
-        }elseif(!is_null($father) && $father->address == $student['address']){
244
-            Security_user::where('id',$student['student_id'])
243
+        }elseif (!is_null($father) && $father->address == $student['address']) {
244
+            Security_user::where('id', $student['student_id'])
245 245
             ->update(['address_area_id' => $father->address_area_id]);
246
-        }elseif(!is_null($mother) && $mother->address == $student['address']){
247
-            Security_user::where('id',$student['student_id'])
246
+        }elseif (!is_null($mother) && $mother->address == $student['address']) {
247
+            Security_user::where('id', $student['student_id'])
248 248
             ->update(['address_area_id' => $mother->address_area_id]);
249
-        }elseif(!is_null($guardian) && $guardian->address == $student['address']){
250
-            Security_user::where('id',$student['student_id'])
249
+        }elseif (!is_null($guardian) && $guardian->address == $student['address']) {
250
+            Security_user::where('id', $student['student_id'])
251 251
             ->update(['address_area_id' => $guardian->address_area_id]);
252 252
         }
253 253
     }
254 254
 
255
-    public static function createOrUpdate($studentId,$row,$params,$file){
255
+    public static function createOrUpdate($studentId, $row, $params, $file) {
256 256
         self::create([
257 257
             'student_status_id' => 1,
258 258
             'student_id' => $studentId,
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -228,25 +228,25 @@
 block discarded – undo
228 228
         if(!is_null($father) && is_null($mother) && is_null($guardian)){
229 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))){
231
+        } elseif(!is_null($mother)  && (is_null($father) && is_null($guardian))){
232 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)){
234
+        } elseif(!is_null($guardian) && is_null($father) && is_null($mother)){
235 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
             Security_user::where('id',$student['student_id'])
239 239
             ->update(['address_area_id' => $mother->address_area_id]);
240
-        }elseif(!is_null($mother)  && !is_null($father) && ($father->address_area_id !==  $mother->address_area_id) && !is_null($guardian)){
240
+        } elseif(!is_null($mother)  && !is_null($father) && ($father->address_area_id !==  $mother->address_area_id) && !is_null($guardian)){
241 241
             Security_user::where('id',$student['student_id'])
242 242
             ->update(['address_area_id' => $guardian->address_area_id]);
243
-        }elseif(!is_null($father) && $father->address == $student['address']){
243
+        } elseif(!is_null($father) && $father->address == $student['address']){
244 244
             Security_user::where('id',$student['student_id'])
245 245
             ->update(['address_area_id' => $father->address_area_id]);
246
-        }elseif(!is_null($mother) && $mother->address == $student['address']){
246
+        } elseif(!is_null($mother) && $mother->address == $student['address']){
247 247
             Security_user::where('id',$student['student_id'])
248 248
             ->update(['address_area_id' => $mother->address_area_id]);
249
-        }elseif(!is_null($guardian) && $guardian->address == $student['address']){
249
+        } elseif(!is_null($guardian) && $guardian->address == $student['address']){
250 250
             Security_user::where('id',$student['student_id'])
251 251
             ->update(['address_area_id' => $guardian->address_area_id]);
252 252
         }
Please login to merge, or discard this patch.
app/Providers/ValidatorExtended.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
             if (empty($value)) {
71 71
                 return false;
72 72
             } elseif ($gradeEntity !== null) {
73
-                $admissionAge = (($gradeEntity->admission_age) * 12) - 1;
73
+                $admissionAge = (($gradeEntity->admission_age)*12) - 1;
74 74
                 $to = $academicPeriod->start_date;
75 75
                 $diff_in_months = $to->diffInMonths($value);
76 76
                 $ageOfStudent = $diff_in_months;
77 77
                 $enrolmentMaximumAge = $admissionAge + 120;
78 78
                 return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge);
79
-            } else {
79
+            }else {
80 80
                 return false;
81 81
             }
82
-        } else {
83
-            $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found';
82
+        }else {
83
+            $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found';
84 84
             $this->_set_custom_stuff();
85 85
             return false;
86 86
         }
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 
92 92
         if (is_numeric($value)) {
93 93
             if ($value < 10) {
94
-                $this->_custom_messages['bmi'] =  $attribute . ' is must greater than 10';
94
+                $this->_custom_messages['bmi'] = $attribute.' is must greater than 10';
95 95
                 $this->_set_custom_stuff();
96 96
                 return false;
97 97
             } elseif ($value > 250) {
98
-                $this->_custom_messages['bmi'] =  $attribute . ' is must smaller than 250';
98
+                $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250';
99 99
                 $this->_set_custom_stuff();
100 100
                 return false;
101 101
             }
102
-        } else {
103
-            $this->_custom_messages['bmi'] =  $attribute . ' is must a valid numeric';
102
+        }else {
103
+            $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric';
104 104
             $this->_set_custom_stuff();
105 105
             return false;
106 106
         }
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
 
110 110
     protected function validateBmi($attribute, $value, $parameters)
111 111
     {
112
-        $bmiGrades =  ['G1', 'G4', 'G7', 'G10'];
112
+        $bmiGrades = ['G1', 'G4', 'G7', 'G10'];
113 113
         $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0])
114 114
             ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id')
115 115
             ->first();
116
-        $educationGrade =  Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first();
116
+        $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first();
117 117
         if (in_array($institutionGrade->code, $bmiGrades)) {
118 118
             if (!empty($value)) {
119 119
                 if (($attribute == 'bmi_height') || ('bmi_weight')) {
120 120
                     return $this->validateHW($attribute, $value);
121 121
                 }
122
-            } else {
123
-                $this->_custom_messages['bmi'] =  $attribute . ' is required for ' . $educationGrade->name;
122
+            }else {
123
+                $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name;
124 124
                 $this->_set_custom_stuff();
125 125
                 return false;
126 126
             }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             if (($attribute == 'bmi_height') || ('bmi_weight')) {
129 129
                 return $this->validateHW($attribute, $value);
130 130
             }
131
-        } else {
131
+        }else {
132 132
             return true;
133 133
         }
134 134
     }
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
     {
138 138
         foreach ($validator->getData() as $data) {
139 139
             if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) {
140
-                $BirthDivision = Area_administrative::where('name', '=',  '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); //
140
+                $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); //
141 141
                 if ($BirthDivision->count() > 0) {
142
-                    $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate']
142
+                    $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate']
143 143
                         ->where('parent_id', '=', $BirthDivision->first()->id)->count();
144
-                    return $BirthArea  > 0;
144
+                    return $BirthArea > 0;
145 145
                 } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) {
146 146
                     $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC';
147 147
                     $this->_set_custom_stuff();
148 148
                     return false;
149
-                } else {
149
+                }else {
150 150
                     return true;
151 151
                 }
152
-            } else {
152
+            }else {
153 153
                 return true;
154 154
             }
155 155
         }
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 
158 158
     protected function validateIsStudentInClass($attribute, $value, $perameters, $validator)
159 159
     {
160
-        $student =  Security_user::where('openemis_no', '=', $value);
160
+        $student = Security_user::where('openemis_no', '=', $value);
161 161
         if ($student->count() > 0) {
162 162
             $student = $student->first()->toArray();
163
-            $check =  Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count();
163
+            $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count();
164 164
             if ($check == 1) {
165 165
                 return true;
166
-            } else {
166
+            }else {
167 167
                 return false;
168 168
             }
169
-        } else {
169
+        }else {
170 170
             return false;
171 171
         }
172 172
     }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     {
178 178
         $valid = true;
179 179
         foreach ($validator->getData() as $data) {
180
-            switch($data[$perameters[0]]){
180
+            switch ($data[$perameters[0]]) {
181 181
                 case 'BC':
182 182
                     $valid = preg_match('/^([0-9]{3,5})/i', $value);
183 183
                     break;
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
         }
191 191
         
192 192
         if ($valid == 0) {
193
-            $this->_custom_messages['identity'] = $attribute . ' is not valid  Please check the NIC number';
193
+            $this->_custom_messages['identity'] = $attribute.' is not valid  Please check the NIC number';
194 194
             $this->_set_custom_stuff();
195 195
             return false;
196
-        } else {
196
+        }else {
197 197
             return true;
198 198
         }
199 199
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     protected function validateUserUnique($attribute, $value, $perameters, $validator)
202 202
     {
203 203
         foreach ($validator->getData() as $data) {
204
-            $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
204
+            $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
205 205
             if ($identityType !== null && ($value !== null)) {
206 206
                 if ($identityType->national_code === 'BC') {
207 207
                     return $this->checkUnique($value, $data, $identityType);
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
     protected function validateIsBc($attribute, $value, $perameters, $validator)
218 218
     {
219 219
         foreach ($validator->getData() as $data) {
220
-            $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
220
+            $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
221 221
             if (($identityType !== null) && ($identityType !== "")) {
222 222
                 if (($identityType->national_code) === 'BC') {
223 223
                     return (strlen((string) $data['identity_number']) < 7);
224
-                } else {
224
+                }else {
225 225
                     return true;
226 226
                 }
227
-            } else {
227
+            }else {
228 228
                 return true;
229 229
             }
230 230
         }
@@ -234,24 +234,24 @@  discard block
 block discarded – undo
234 234
     {
235 235
         $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id);
236 236
         if ($isUnique->count() > 0) {
237
-            $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no;
237
+            $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no;
238 238
             $this->_set_custom_stuff();
239 239
             return false;
240
-        } else {
240
+        }else {
241 241
             return true;
242 242
         }
243 243
     }
244 244
 
245 245
     protected function IsBc($data, $value)
246 246
     {
247
-        $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
247
+        $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
248 248
         if ($identityType !== null) {
249 249
             if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) {
250 250
                 return false;
251
-            } else {
251
+            }else {
252 252
                 return true;
253 253
             }
254
-        } else {
254
+        }else {
255 255
             return true;
256 256
         }
257 257
     }
Please login to merge, or discard this patch.