@@ -52,9 +52,9 @@ |
||
52 | 52 | $value = self::where('st_no', $data['st_no'])->get(); |
53 | 53 | if (count($value) > 0) { |
54 | 54 | self::where('st_no', $data['st_no'])->update($data); |
55 | - } else { |
|
55 | + }else { |
|
56 | 56 | self::insert($data); |
57 | 57 | } |
58 | - $output->writeln('Student name: ' . ($data['f_name']) . ' has been inserted to the database'); |
|
58 | + $output->writeln('Student name: '.($data['f_name']).' has been inserted to the database'); |
|
59 | 59 | } |
60 | 60 | } |
@@ -15,13 +15,13 @@ |
||
15 | 15 | */ |
16 | 16 | public function handle($request, Closure $next) |
17 | 17 | { |
18 | - if($request->user()->super_admin == 1){ |
|
18 | + if ($request->user()->super_admin == 1) { |
|
19 | 19 | return $next($request); |
20 | - }elseif ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { |
|
20 | + }elseif ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { |
|
21 | 21 | return $next($request); |
22 | - }elseif($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL'){ |
|
22 | + }elseif ($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL') { |
|
23 | 23 | return $next($request); |
24 | - }elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){ |
|
24 | + }elseif ($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL') { |
|
25 | 25 | return $next($request); |
26 | 26 | } |
27 | 27 | return redirect('/login')->with('status', 'Your dont have access for upload data. Please get assign your to the class and try'); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function importExportView() |
36 | 36 | { |
37 | - if(Auth::user()->super_admin ){ |
|
37 | + if (Auth::user()->super_admin) { |
|
38 | 38 | return view('uploadcsv'); |
39 | - }else{ |
|
40 | - $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; |
|
41 | - return view('importExport')->with('classes',$classes); |
|
39 | + }else { |
|
40 | + $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; |
|
41 | + return view('importExport')->with('classes', $classes); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | |
74 | 74 | |
75 | 75 | $import = new UsersImport(); |
76 | - try{ |
|
76 | + try { |
|
77 | 77 | $files = Storage::disk('sis-bulk-data-files')->allFiles(); |
78 | - Excel::import($import,request()->file('import_file')); |
|
78 | + Excel::import($import, request()->file('import_file')); |
|
79 | 79 | }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
80 | 80 | $failures = $e->failures(); |
81 | 81 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public static function boot() |
64 | 64 | { |
65 | 65 | parent::boot(); |
66 | - self::creating(function ($model) { |
|
66 | + self::creating(function($model) { |
|
67 | 67 | $model->id = (string) Uuid::generate(4); |
68 | 68 | $model->created = now(); |
69 | 69 | }); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public static function createExaminationData($student, $admissionInfo) |
134 | 134 | { |
135 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
135 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
136 | 136 | try { |
137 | 137 | self::create([ |
138 | 138 | 'id' => (string) Uuid::generate(4), |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'created' => now(), |
157 | 157 | 'created_user_id' => 1 |
158 | 158 | ]); |
159 | - } catch (\Throwable $th) { |
|
159 | + }catch (\Throwable $th) { |
|
160 | 160 | Log::error($th); |
161 | 161 | } |
162 | 162 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public static function updateExaminationData($student, $admissionInfo) |
172 | 172 | { |
173 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
173 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
174 | 174 | try { |
175 | 175 | self::where([ |
176 | 176 | 'student_id' => $student['student_id'], |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'modified_user_id' => 1 |
192 | 192 | ] |
193 | 193 | ); |
194 | - } catch (\Throwable $th) { |
|
194 | + }catch (\Throwable $th) { |
|
195 | 195 | Log::error($th); |
196 | 196 | } |
197 | 197 | } |
@@ -70,17 +70,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | { |
175 | 175 | $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value); |
176 | 176 | if (!$valid) { |
177 | - $this->_custom_messages['nic'] = $attribute . ' is not valid, Please check the NIC number'; |
|
177 | + $this->_custom_messages['nic'] = $attribute.' is not valid, Please check the NIC number'; |
|
178 | 178 | $this->_set_custom_stuff(); |
179 | 179 | return false; |
180 | - } else { |
|
180 | + }else { |
|
181 | 181 | return true; |
182 | 182 | } |
183 | 183 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | protected function validateUserUnique($attribute, $value, $perameters, $validator) |
186 | 186 | { |
187 | 187 | foreach ($validator->getData() as $data) { |
188 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
188 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
189 | 189 | if ($identityType !== null && ($value !== null)) { |
190 | 190 | if ($identityType->national_code === 'BC') { |
191 | 191 | return $this->checkUnique($value, $data, $identityType); |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | protected function validateIsBc($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) && ($identityType !== "")) { |
206 | 206 | if (($identityType->national_code) === 'BC') { |
207 | 207 | return (strlen((string) $data['identity_number']) < 7); |
208 | - } else { |
|
208 | + }else { |
|
209 | 209 | return true; |
210 | 210 | } |
211 | - } else { |
|
211 | + }else { |
|
212 | 212 | return true; |
213 | 213 | } |
214 | 214 | } |
@@ -218,24 +218,24 @@ discard block |
||
218 | 218 | { |
219 | 219 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
220 | 220 | if ($isUnique->count() > 0) { |
221 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
221 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
222 | 222 | $this->_set_custom_stuff(); |
223 | 223 | return false; |
224 | - } else { |
|
224 | + }else { |
|
225 | 225 | return true; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | 229 | protected function IsBc($data, $value) |
230 | 230 | { |
231 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
231 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
232 | 232 | if ($identityType !== null) { |
233 | 233 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
234 | 234 | return false; |
235 | - } else { |
|
235 | + }else { |
|
236 | 236 | return true; |
237 | 237 | } |
238 | - } else { |
|
238 | + }else { |
|
239 | 239 | return true; |
240 | 240 | } |
241 | 241 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | if (!empty($isAvailableforPromotion)) { |
64 | 64 | $this->process($institutionGrade, $nextGrade, $year, 1); |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | $this->process($institutionGrade, $nextGrade, $year, 3); |
67 | 67 | } |
68 | 68 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
98 | 98 | $output->writeln('##########################################################################################################################'); |
99 | - $output->writeln('Promoting from ' . $institutionGrade['name'] . ' IN ' . $institution->name . ' No of Students: ' . count($studentListToPromote)); |
|
99 | + $output->writeln('Promoting from '.$institutionGrade['name'].' IN '.$institution->name.' No of Students: '.count($studentListToPromote)); |
|
100 | 100 | |
101 | 101 | |
102 | 102 | if (!empty($parallelClasses)) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | array_walk($studentListToPromote, array($this, 'assingeToClasses'), $params); |
111 | 111 | array_walk($parallelClasses, array($this, 'updateStudentCount')); |
112 | 112 | } |
113 | - } catch (\Exception $e) { |
|
113 | + }catch (\Exception $e) { |
|
114 | 114 | dd($e); |
115 | 115 | Log::error($e->getMessage()); |
116 | 116 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $nextAcademicPeriod = Academic_period::query()->where('code', $year)->get()->first(); |
146 | 146 | |
147 | 147 | $nextGradeObj = null; |
148 | - if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
148 | + if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
149 | 149 | $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $institutionGrade['education_grade_id'], $academicPeriod->id); |
150 | 150 | $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $nextGrade->id, $nextAcademicPeriod->id); |
151 | 151 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | // promote parallel classes |
156 | 156 | $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $nextGradeObj->toArray(), 1); |
157 | 157 | return 1; |
158 | - } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
158 | + } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
159 | 159 | // promote pool promotion |
160 | 160 | $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 1); |
161 | 161 | return 2; |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | // Promote matching class name with previous class |
164 | 164 | $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $nextGradeObj->toArray(), 1); |
165 | 165 | return 1; |
166 | - } else { |
|
166 | + }else { |
|
167 | 167 | // default pool promotion |
168 | 168 | $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 1); |
169 | 169 | return 2; |
170 | 170 | } |
171 | - } else { |
|
171 | + }else { |
|
172 | 172 | // default pool promotion |
173 | 173 | $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 3); |
174 | 174 | return 2; |
@@ -204,10 +204,10 @@ discard block |
||
204 | 204 | ]; |
205 | 205 | |
206 | 206 | try { |
207 | - Institution_student::where('id', (string)$student['id'])->update($studentData); |
|
207 | + Institution_student::where('id', (string) $student['id'])->update($studentData); |
|
208 | 208 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
209 | - $output->writeln('----------------- ' . $student['admission_id'] . ' to ' . $studentData['education_grade_id']); |
|
210 | - } catch (\Exception $e) { |
|
209 | + $output->writeln('----------------- '.$student['admission_id'].' to '.$studentData['education_grade_id']); |
|
210 | + }catch (\Exception $e) { |
|
211 | 211 | dd($e); |
212 | 212 | Log::error($e->getMessage()); |
213 | 213 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $studentClass = $this->institution_class_students->getStudentNewClass($student); |
229 | 229 | if (!is_null($studentClass)) { |
230 | 230 | return array_search(str_replace($educationGrade['name'], $nextGrade->name, $studentClass->name), array_column($classes, 'name')); |
231 | - } else { |
|
231 | + }else { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | } |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | if (!$this->institution_class_students->isDuplicated($studentObj)) { |
281 | 281 | $this->institution_class_students->create($studentObj); |
282 | 282 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
283 | - $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']); |
|
284 | - } else { |
|
285 | - $this->institution_class_students->where('id', (string)$student['id'])->update($studentObj); |
|
283 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
284 | + }else { |
|
285 | + $this->institution_class_students->where('id', (string) $student['id'])->update($studentObj); |
|
286 | 286 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
287 | - $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']); |
|
287 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | class DashboardViewsController extends Controller |
9 | 9 | { |
10 | 10 | |
11 | - public function callback(){ |
|
11 | + public function callback() { |
|
12 | 12 | |
13 | 13 | /** Total number of students by institutions |
14 | 14 | * In Grafana query to get total students count |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | use Maatwebsite\Excel\Concerns\WithBatchInserts; |
19 | 19 | use Maatwebsite\Excel\Concerns\WithChunkReading; |
20 | 20 | |
21 | -class ExaminationStudentsImport implements ToModel, WithStartRow, WithHeadingRow, WithChunkReading, WithBatchInserts , WithValidation ,WithMapping, SkipsOnFailure, SkipsOnError |
|
21 | +class ExaminationStudentsImport implements ToModel, WithStartRow, WithHeadingRow, WithChunkReading, WithBatchInserts, WithValidation, WithMapping, SkipsOnFailure, SkipsOnError |
|
22 | 22 | { |
23 | - use Importable , SkipsFailures, SkipsErrors; |
|
23 | + use Importable, SkipsFailures, SkipsErrors; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @return int |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | |
58 | 58 | private function transformDateTime(string $value, string $format = 'm/d/Y') |
59 | 59 | { |
60 | - try{ |
|
60 | + try { |
|
61 | 61 | $date = date_create_from_format('m/d/Y', $value); |
62 | - if(gettype($date)=='boolean'){ |
|
62 | + if (gettype($date) == 'boolean') { |
|
63 | 63 | $date = date_create_from_format('Y-m-d', $value); |
64 | 64 | } |
65 | 65 | $date = date_format($date, 'Y-m-d'); |
66 | 66 | return $date; |
67 | - }catch(\Exception $e){ |
|
67 | + }catch (\Exception $e) { |
|
68 | 68 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
69 | 69 | $failure = new Failure(2, 'remark', [0 => 'The given date is wrong']); |
70 | 70 | $failures = [0 => $failure]; |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
89 | 89 | $higestRow = 0; |
90 | 90 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
91 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
91 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
92 | 92 | if (isEmptyRow(reset($rowData))) { |
93 | 93 | continue; |
94 | - } else { |
|
94 | + }else { |
|
95 | 95 | $higestRow += 1; |
96 | 96 | } |
97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->failures = []; |
106 | 106 | if (($column !== "") && (!in_array($column, $columns))) { |
107 | 107 | $this->isValidSheet = false; |
108 | - $this->error[] = 'Unsupported column found ,remove:' . $column; |
|
108 | + $this->error[] = 'Unsupported column found ,remove:'.$column; |
|
109 | 109 | $this->failure = new Failure(3, 'remark', $this->error, [null]); |
110 | 110 | $this->failures = new \Maatwebsite\Excel\Validators\ValidationException($error, [$this->failure]); |
111 | 111 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | { |
119 | 119 | $columns = Config::get('excel.columns'); |
120 | 120 | $optional_columns = Config::get('excel.optional_columns'); |
121 | - $columns = array_diff ($columns,$optional_columns); |
|
121 | + $columns = array_diff($columns, $optional_columns); |
|
122 | 122 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
123 | 123 | $this->failures = []; |
124 | 124 | foreach ($columns as $column) { |
125 | 125 | if (($column !== "") && (!in_array($column, $existingColumns))) { |
126 | 126 | $this->isValidSheet = false; |
127 | - $this->error[] = 'Missing Column :' . $column . ' Not found'; |
|
127 | + $this->error[] = 'Missing Column :'.$column.' Not found'; |
|
128 | 128 | $this->failure = new Failure(3, 'remark', $this->error, [null]); |
129 | 129 | $this->failures = new \Maatwebsite\Excel\Validators\ValidationException($error, [$this->failure]); |
130 | 130 | } |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | $highestColumn = $this->worksheet->getHighestDataColumn(3); |
142 | 142 | $higestRow = 1; |
143 | 143 | for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { |
144 | - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); |
|
144 | + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); |
|
145 | 145 | if (isEmptyRow(reset($rowData))) { |
146 | 146 | continue; |
147 | - } else { |
|
147 | + }else { |
|
148 | 148 | $higestRow += 1; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | if ($higestRow == 0) { |
152 | 152 | exit; |
153 | - } else { |
|
153 | + }else { |
|
154 | 154 | return $higestRow; |
155 | 155 | } |
156 | 156 | } |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | case 'string': |
176 | 176 | $row[$column] = preg_replace('/[^A-Za-z0-9\-]/', '-', $row[$column]); |
177 | 177 | $row[$column] = date($format, strtotime($row[$column])); //date($row[$column]); |
178 | - $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
178 | + $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); |
|
179 | 179 | break; |
180 | 180 | case 'double'; |
181 | - $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
181 | + $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); |
|
182 | 182 | break; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | return $row; |
186 | - } catch (Exception $e) { |
|
186 | + }catch (Exception $e) { |
|
187 | 187 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
188 | - $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]); |
|
188 | + $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 | 189 | $failures = [0 => $failure]; |
190 | 190 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
191 | 191 | } |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | $row = $this->formateDate($row, 'mothers_date_of_birth_yyyy_mm_dd'); |
207 | 207 | $row = $this->formateDate($row, 'guardians_date_of_birth_yyyy_mm_dd'); |
208 | 208 | |
209 | - $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
209 | + $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); |
|
210 | 210 | if ($row['identity_type'] == 'BC' && (!empty($row['birth_divisional_secretariat'])) && ($row['identity_number'] !== null) && $row['date_of_birth_yyyy_mm_dd'] !== null) { |
211 | - $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
211 | + $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); |
|
212 | 212 | // dd(($row['date_of_birth_yyyy_mm_dd'])); |
213 | - $BirthDivision = Area_administrative::where('name', 'like', '%' . $row['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5)->first(); |
|
213 | + $BirthDivision = Area_administrative::where('name', 'like', '%'.$row['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5)->first(); |
|
214 | 214 | if ($BirthDivision !== null) { |
215 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%') |
|
215 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%') |
|
216 | 216 | ->where('parent_id', '=', $BirthDivision->id)->first(); |
217 | 217 | if ($BirthArea !== null) { |
218 | - $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"); |
|
218 | + $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"); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | { |
228 | 228 | if (array_key_exists($key, $row)) { |
229 | 229 | return true; |
230 | - } else { |
|
230 | + }else { |
|
231 | 231 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
232 | - $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]); |
|
232 | + $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]); |
|
233 | 233 | $failures = [0 => $failure]; |
234 | 234 | new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
235 | 235 | }; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | if ($exceededStudents == true) { |
267 | 267 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
268 | - $failure = new Failure(3, 'remark', ['Class student count exceeded! Max number of students is' . $institutionClass->no_of_students], [null]); |
|
268 | + $failure = new Failure(3, 'remark', ['Class student count exceeded! Max number of students is'.$institutionClass->no_of_students], [null]); |
|
269 | 269 | $failures = [0 => $failure]; |
270 | 270 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
271 | 271 | Log::info('email-sent', [$this->file]); |
272 | - } else { |
|
272 | + }else { |
|
273 | 273 | return true; |
274 | 274 | } |
275 | 275 | } |