@@ -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 |
@@ -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 | } |
@@ -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 | } |
@@ -10,10 +10,10 @@ |
||
10 | 10 | public function register() {} |
11 | 11 | |
12 | 12 | public function boot() { |
13 | - $this->app->validator->resolver( function( $translator, $data, $rules, |
|
14 | - $messages = array(), $customAttributes = array() ) { |
|
15 | - return new ValidatorExtended( $translator, $data, $rules, $messages, |
|
16 | - $customAttributes ); |
|
13 | + $this->app->validator->resolver(function($translator, $data, $rules, |
|
14 | + $messages = array(), $customAttributes = array()) { |
|
15 | + return new ValidatorExtended($translator, $data, $rules, $messages, |
|
16 | + $customAttributes); |
|
17 | 17 | } ); |
18 | 18 | } |
19 | 19 | } |