@@ -18,10 +18,10 @@ |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * @param array $row |
|
22 | - * |
|
23 | - * @return \Illuminate\Database\Eloquent\Model|null |
|
24 | - */ |
|
21 | + * @param array $row |
|
22 | + * |
|
23 | + * @return \Illuminate\Database\Eloquent\Model|null |
|
24 | + */ |
|
25 | 25 | |
26 | 26 | public function sheets(): array |
27 | 27 | { |
@@ -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 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | - public function boot() |
|
29 | - { |
|
30 | - // |
|
31 | - if((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { |
|
32 | - URL::forceScheme('https'); |
|
33 | - } |
|
34 | - } |
|
28 | + public function boot() |
|
29 | + { |
|
30 | + // |
|
31 | + if((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { |
|
32 | + URL::forceScheme('https'); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -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 | } |
@@ -135,13 +135,13 @@ |
||
135 | 135 | } |
136 | 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'; |
|
140 | - $this->_set_custom_stuff(); |
|
141 | - return false; |
|
142 | - }else{ |
|
143 | - return true; |
|
144 | - } |
|
138 | + if(!$valid){ |
|
139 | + $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; |
|
140 | + $this->_set_custom_stuff(); |
|
141 | + return false; |
|
142 | + }else{ |
|
143 | + return true; |
|
144 | + } |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | protected function validateUserUnique($attribute, $value, $perameters, $validator) { |
@@ -56,43 +56,43 @@ discard block |
||
56 | 56 | if (empty($value)) { |
57 | 57 | return false; |
58 | 58 | } elseif ($gradeEntity !== null) { |
59 | - $admissionAge = (($gradeEntity->admission_age)*12)-1; |
|
59 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
60 | 60 | $to = $academicPeriod->start_date; |
61 | 61 | $diff_in_months = $to->diffInMonths($value); |
62 | 62 | $ageOfStudent = $diff_in_months; |
63 | 63 | $enrolmentMaximumAge = $admissionAge + 120; |
64 | 64 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | protected function validateBmi($attribute, $value, $parameters) |
71 | 71 | { |
72 | - $bmiGrades = ['G1','G4','G7','G10']; |
|
72 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
73 | 73 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
74 | - ->join('education_grades','institution_class_grades.education_grade_id','education_grades.id') |
|
74 | + ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
|
75 | 75 | ->first(); |
76 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
77 | - if(in_array($institutionGrade->code,$bmiGrades)){ |
|
78 | - if(!empty($value)){ |
|
79 | - if(($attribute == 'bmi_height') || ('bmi_weight')){ |
|
76 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
77 | + if (in_array($institutionGrade->code, $bmiGrades)) { |
|
78 | + if (!empty($value)) { |
|
79 | + if (($attribute == 'bmi_height') || ('bmi_weight')) { |
|
80 | 80 | $v = Validator::make([$attribute => $value], [ |
81 | 81 | $attribute => 'number|min:10|max:200' |
82 | 82 | ]); |
83 | - if($v->fails()) { |
|
84 | - $this->_custom_messages['bmi'] = $attribute.' is not a valid input'; |
|
83 | + if ($v->fails()) { |
|
84 | + $this->_custom_messages['bmi'] = $attribute.' is not a valid input'; |
|
85 | 85 | $this->_set_custom_stuff(); |
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | return true; |
89 | 89 | } |
90 | - }else{ |
|
91 | - $this->_custom_messages['bmi'] = $attribute.' is required for '. $educationGrade->name; |
|
90 | + }else { |
|
91 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
92 | 92 | $this->_set_custom_stuff(); |
93 | 93 | return false; |
94 | 94 | } |
95 | - }else{ |
|
95 | + }else { |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | } |
@@ -100,58 +100,58 @@ discard block |
||
100 | 100 | protected function validateBirthPlace($attribute, $value, $perameters, $validator) { |
101 | 101 | foreach ($validator->getData() as $data) { |
102 | 102 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
103 | - $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
104 | - if ($BirthDivision->count() > 0 ) { |
|
105 | - $BirthArea = Area_administrative::where('name', '=', '%'. $value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
103 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
104 | + if ($BirthDivision->count() > 0) { |
|
105 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
106 | 106 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
107 | - return $BirthArea > 0; |
|
107 | + return $BirthArea > 0; |
|
108 | 108 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
109 | 109 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
110 | 110 | $this->_set_custom_stuff(); |
111 | 111 | return false; |
112 | - } else { |
|
112 | + }else { |
|
113 | 113 | return true; |
114 | 114 | } |
115 | - } else { |
|
115 | + }else { |
|
116 | 116 | return true; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) { |
122 | - $student = Security_user::where('openemis_no', '=', $value); |
|
123 | - if($student->count() > 0){ |
|
122 | + $student = Security_user::where('openemis_no', '=', $value); |
|
123 | + if ($student->count() > 0) { |
|
124 | 124 | $student = $student->first()->toArray(); |
125 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id','=',$perameters[0])->count(); |
|
126 | - if($check == 1){ |
|
125 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
126 | + if ($check == 1) { |
|
127 | 127 | return true; |
128 | - }else{ |
|
128 | + }else { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | - }else{ |
|
131 | + }else { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | - protected function validateNic($attribute, $value, $perameters, $validator){ |
|
136 | + protected function validateNic($attribute, $value, $perameters, $validator) { |
|
137 | 137 | $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value); |
138 | - if(!$valid){ |
|
139 | - $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; |
|
138 | + if (!$valid) { |
|
139 | + $this->_custom_messages['nic'] = $attribute.' is not valid, Please check the NIC number'; |
|
140 | 140 | $this->_set_custom_stuff(); |
141 | 141 | return false; |
142 | - }else{ |
|
142 | + }else { |
|
143 | 143 | return true; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | protected function validateUserUnique($attribute, $value, $perameters, $validator) { |
148 | 148 | foreach ($validator->getData() as $data) { |
149 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
149 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
150 | 150 | if ($identityType !== null && ($value !== null)) { |
151 | 151 | if ($identityType->national_code === 'BC') { |
152 | - return $this->checkUnique($value, $data,$identityType); |
|
152 | + return $this->checkUnique($value, $data, $identityType); |
|
153 | 153 | } elseif ($identityType->national_code === 'NIC') { |
154 | - return $this->checkUnique($value, $data,$identityType); |
|
154 | + return $this->checkUnique($value, $data, $identityType); |
|
155 | 155 | } |
156 | 156 | } elseif (($value == null) || $value == "") { |
157 | 157 | return true; |
@@ -161,39 +161,39 @@ discard block |
||
161 | 161 | |
162 | 162 | protected function validateIsBc($attribute, $value, $perameters, $validator) { |
163 | 163 | foreach ($validator->getData() as $data) { |
164 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
164 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
165 | 165 | if (($identityType !== null) && ($identityType !== "")) { |
166 | 166 | if (($identityType->national_code) === 'BC') { |
167 | 167 | return (strlen((string) $data['identity_number']) < 7); |
168 | - } else { |
|
168 | + }else { |
|
169 | 169 | return true; |
170 | 170 | } |
171 | - } else { |
|
171 | + }else { |
|
172 | 172 | return true; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - protected function checkUnique($value, $data,$identityType) { |
|
177 | + protected function checkUnique($value, $data, $identityType) { |
|
178 | 178 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
179 | 179 | if ($isUnique->count() > 0) { |
180 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
180 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
181 | 181 | $this->_set_custom_stuff(); |
182 | 182 | return false; |
183 | - } else { |
|
183 | + }else { |
|
184 | 184 | return true; |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | protected function IsBc($data, $value) { |
189 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
189 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
190 | 190 | if ($identityType !== null) { |
191 | 191 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
192 | 192 | return false; |
193 | - } else { |
|
193 | + }else { |
|
194 | 194 | return true; |
195 | 195 | } |
196 | - } else { |
|
196 | + }else { |
|
197 | 197 | return true; |
198 | 198 | } |
199 | 199 | } |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | } |
88 | 88 | return true; |
89 | 89 | } |
90 | - }else{ |
|
90 | + } else{ |
|
91 | 91 | $this->_custom_messages['bmi'] = $attribute.' is required for '. $educationGrade->name; |
92 | 92 | $this->_set_custom_stuff(); |
93 | 93 | return false; |
94 | 94 | } |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | } |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id','=',$perameters[0])->count(); |
126 | 126 | if($check == 1){ |
127 | 127 | return true; |
128 | - }else{ |
|
128 | + } else{ |
|
129 | 129 | return false; |
130 | 130 | } |
131 | - }else{ |
|
131 | + } else{ |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; |
140 | 140 | $this->_set_custom_stuff(); |
141 | 141 | return false; |
142 | - }else{ |
|
142 | + } else{ |
|
143 | 143 | return true; |
144 | 144 | } |
145 | 145 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | public function boot() { |
13 | 13 | $this->app->validator->resolver( function( $translator, $data, $rules, |
14 | - $messages = array(), $customAttributes = array() ) { |
|
14 | + $messages = array(), $customAttributes = array() ) { |
|
15 | 15 | return new ValidatorExtended( $translator, $data, $rules, $messages, |
16 | 16 | $customAttributes ); |
17 | 17 | } ); |
@@ -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 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function register() |
14 | 14 | { |
15 | - $this->app->singleton('hash',function (){ |
|
15 | + $this->app->singleton('hash', function() { |
|
16 | 16 | return new SHAHasher($this->app); |
17 | 17 | }); |
18 | 18 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | protected function mapWebRoutes() |
53 | 53 | { |
54 | 54 | Route::middleware('web') |
55 | - ->namespace($this->namespace) |
|
56 | - ->group(base_path('routes/web.php')); |
|
55 | + ->namespace($this->namespace) |
|
56 | + ->group(base_path('routes/web.php')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | protected function mapApiRoutes() |
67 | 67 | { |
68 | 68 | Route::prefix('api') |
69 | - ->middleware('api') |
|
70 | - ->namespace($this->namespace) |
|
71 | - ->group(base_path('routes/api.php')); |
|
69 | + ->middleware('api') |
|
70 | + ->namespace($this->namespace) |
|
71 | + ->group(base_path('routes/api.php')); |
|
72 | 72 | } |
73 | 73 | } |
@@ -212,7 +212,7 @@ |
||
212 | 212 | 'created_user_id' => $student['created_user_id'] |
213 | 213 | ]; |
214 | 214 | try{ |
215 | - Institution_student::where('id',(string)$student['id'])->update($studentData); |
|
215 | + Institution_student::where('id',(string)$student['id'])->update($studentData); |
|
216 | 216 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
217 | 217 | $output->writeln('----------------- '. $student['admission_id'] . ' to ' . $studentData['education_grade_id']); |
218 | 218 |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | { |
64 | 64 | $year = $this->argument('year'); |
65 | 65 | $institution = $this->argument('institution'); |
66 | - $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($year,$institution); |
|
66 | + $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($year, $institution); |
|
67 | 67 | // dd($institutionGrade); |
68 | - array_walk($institutionGrade,array($this,'processGrades'),$year); |
|
68 | + array_walk($institutionGrade, array($this, 'processGrades'), $year); |
|
69 | 69 | } |
70 | 70 | |
71 | - public function processGrades($institutionGrade,$count,$year){ |
|
72 | - if(!empty($institutionGrade) && $this->institutions->isActive($institutionGrade['institution_id'])) { |
|
73 | - $this->instituion_grade->updatePromoted($year,$institutionGrade['id']); |
|
71 | + public function processGrades($institutionGrade, $count, $year) { |
|
72 | + if (!empty($institutionGrade) && $this->institutions->isActive($institutionGrade['institution_id'])) { |
|
73 | + $this->instituion_grade->updatePromoted($year, $institutionGrade['id']); |
|
74 | 74 | $isAvailableforPromotion = 0; |
75 | 75 | $nextGrade = $this->education_grades->getNextGrade($institutionGrade['education_grade_id']); |
76 | 76 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | if (!empty($isAvailableforPromotion)) { |
82 | - $this->process($institutionGrade,$nextGrade,$year,1); |
|
83 | - }else{ |
|
84 | - $this->process($institutionGrade,$nextGrade,$year,3); |
|
82 | + $this->process($institutionGrade, $nextGrade, $year, 1); |
|
83 | + }else { |
|
84 | + $this->process($institutionGrade, $nextGrade, $year, 3); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param array $parallelClasses |
98 | 98 | * @param $status |
99 | 99 | */ |
100 | - public function promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$parallelClasses = [],$status){ |
|
101 | - $institution = Institution::where( 'id',$institutionGrade['institution_id'])->get()->first(); |
|
102 | - $studentListToPromote = $this->institution_students->getStudentListToPromote($institutionGrade,$academicPeriod); |
|
100 | + public function promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $parallelClasses = [], $status) { |
|
101 | + $institution = Institution::where('id', $institutionGrade['institution_id'])->get()->first(); |
|
102 | + $studentListToPromote = $this->institution_students->getStudentListToPromote($institutionGrade, $academicPeriod); |
|
103 | 103 | |
104 | 104 | $params = [ |
105 | 105 | $nextAcademicPeriod, |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | $status |
109 | 109 | ]; |
110 | 110 | |
111 | - try{ |
|
112 | - array_walk($studentListToPromote,array($this,'promote'),$params); |
|
111 | + try { |
|
112 | + array_walk($studentListToPromote, array($this, 'promote'), $params); |
|
113 | 113 | |
114 | 114 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
115 | 115 | $output->writeln('##########################################################################################################################'); |
116 | - $output->writeln('Promoting from '. $institutionGrade['name'] .' IN '.$institution->name.' No of Students: '. count($studentListToPromote)); |
|
116 | + $output->writeln('Promoting from '.$institutionGrade['name'].' IN '.$institution->name.' No of Students: '.count($studentListToPromote)); |
|
117 | 117 | |
118 | 118 | |
119 | - if(!empty($parallelClasses)){ |
|
119 | + if (!empty($parallelClasses)) { |
|
120 | 120 | $params = [ |
121 | 121 | $nextAcademicPeriod, |
122 | 122 | $institutionGrade, |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | $parallelClasses, |
125 | 125 | $status |
126 | 126 | ]; |
127 | - array_walk($studentListToPromote,array($this,'assingeToClasses'),$params); |
|
128 | - array_walk($parallelClasses,array($this,'updateStudentCount')); |
|
127 | + array_walk($studentListToPromote, array($this, 'assingeToClasses'), $params); |
|
128 | + array_walk($parallelClasses, array($this, 'updateStudentCount')); |
|
129 | 129 | } |
130 | - }catch (\Exception $e){ |
|
130 | + }catch (\Exception $e) { |
|
131 | 131 | dd($e); |
132 | 132 | Log::error($e->getMessage()); |
133 | 133 | } |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | |
138 | - public function updateStudentCount($class){ |
|
138 | + public function updateStudentCount($class) { |
|
139 | 139 | $studentCounts = Institution_class_student::getStudentsCount($class['id']); |
140 | 140 | unset($studentCounts['total']); |
141 | - Institution_class::query()->where('id',$class['id'])->update($studentCounts); |
|
141 | + Institution_class::query()->where('id', $class['id'])->update($studentCounts); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -150,38 +150,38 @@ discard block |
||
150 | 150 | * @param $year |
151 | 151 | * @return int |
152 | 152 | */ |
153 | - public function process($institutionGrade,$nextGrade,$year){ |
|
154 | - $academicPeriod = Academic_period::query()->where('code',$year -1)->get()->first(); |
|
155 | - $nextAcademicPeriod = Academic_period::query()->where('code',$year)->get()->first(); |
|
153 | + public function process($institutionGrade, $nextGrade, $year) { |
|
154 | + $academicPeriod = Academic_period::query()->where('code', $year - 1)->get()->first(); |
|
155 | + $nextAcademicPeriod = Academic_period::query()->where('code', $year)->get()->first(); |
|
156 | 156 | |
157 | 157 | $nextGradeObj = null; |
158 | - if($nextGrade !== [] && !is_null($nextGrade) ){ |
|
159 | - $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'],$institutionGrade['institution_id'],$institutionGrade['education_grade_id'],$academicPeriod->id); |
|
160 | - $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'],$institutionGrade['institution_id'],$nextGrade->id,$nextAcademicPeriod->id); |
|
158 | + if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
159 | + $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $institutionGrade['education_grade_id'], $academicPeriod->id); |
|
160 | + $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $nextGrade->id, $nextAcademicPeriod->id); |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | - if(!is_null($nextGradeObj)){ |
|
165 | - if($nextGradeObj->count() == 1){ |
|
164 | + if (!is_null($nextGradeObj)) { |
|
165 | + if ($nextGradeObj->count() == 1) { |
|
166 | 166 | // promote parallel classes |
167 | - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$nextGradeObj->toArray(),1); |
|
167 | + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $nextGradeObj->toArray(), 1); |
|
168 | 168 | return 1; |
169 | - }elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())){ |
|
169 | + }elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
170 | 170 | // promote pool promotion |
171 | - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],1); |
|
171 | + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 1); |
|
172 | 172 | return 2; |
173 | - }elseif(($nextGradeObj->count() > 1) && $currentGradeObj->count() == $nextGradeObj->count()){ |
|
173 | + }elseif (($nextGradeObj->count() > 1) && $currentGradeObj->count() == $nextGradeObj->count()) { |
|
174 | 174 | // Promote matching class name with previous class |
175 | - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$nextGradeObj->toArray(),1); |
|
175 | + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $nextGradeObj->toArray(), 1); |
|
176 | 176 | return 1; |
177 | - }else{ |
|
177 | + }else { |
|
178 | 178 | // default pool promotion |
179 | - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],1); |
|
179 | + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 1); |
|
180 | 180 | return 2; |
181 | 181 | } |
182 | - }else{ |
|
182 | + }else { |
|
183 | 183 | // default pool promotion |
184 | - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],3); |
|
184 | + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 3); |
|
185 | 185 | return 2; |
186 | 186 | } |
187 | 187 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param $count |
195 | 195 | * @param $params |
196 | 196 | */ |
197 | - public function promote($student,$count,$params){ |
|
197 | + public function promote($student, $count, $params) { |
|
198 | 198 | |
199 | 199 | $academicPeriod = $params[0]; |
200 | 200 | $nextGrade = $params[2]; |
@@ -204,19 +204,19 @@ discard block |
||
204 | 204 | 'education_grade_id' => $nextGrade !== null ? $nextGrade->id : $student['education_grade_id'], |
205 | 205 | 'academic_period_id' => $academicPeriod->id, |
206 | 206 | 'start_date' => $academicPeriod->start_date, |
207 | - 'start_year' =>$academicPeriod->start_year , |
|
207 | + 'start_year' =>$academicPeriod->start_year, |
|
208 | 208 | 'end_date' => $academicPeriod->end_date, |
209 | - 'end_year' => $academicPeriod->end_year , |
|
209 | + 'end_year' => $academicPeriod->end_year, |
|
210 | 210 | 'institution_id' => $student['institution_id'], |
211 | 211 | 'admission_id' => $student['admission_id'], |
212 | 212 | 'created_user_id' => $student['created_user_id'] |
213 | 213 | ]; |
214 | - try{ |
|
215 | - Institution_student::where('id',(string)$student['id'])->update($studentData); |
|
214 | + try { |
|
215 | + Institution_student::where('id', (string) $student['id'])->update($studentData); |
|
216 | 216 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
217 | - $output->writeln('----------------- '. $student['admission_id'] . ' to ' . $studentData['education_grade_id']); |
|
217 | + $output->writeln('----------------- '.$student['admission_id'].' to '.$studentData['education_grade_id']); |
|
218 | 218 | |
219 | - }catch (\Exception $e){ |
|
219 | + }catch (\Exception $e) { |
|
220 | 220 | dd($e); |
221 | 221 | Log::error($e->getMessage()); |
222 | 222 | } |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | * @param $classes |
233 | 233 | * @return false|int|string|null |
234 | 234 | */ |
235 | - public function getStudentClass($student,$educationGrade,$nextGrade,$classes){ |
|
235 | + public function getStudentClass($student, $educationGrade, $nextGrade, $classes) { |
|
236 | 236 | $studentClass = $this->institution_class_students->getStudentNewClass($student); |
237 | - if(!is_null($studentClass)){ |
|
238 | - return array_search(str_replace($educationGrade['name'],$nextGrade->name,$studentClass->name),array_column($classes,'name')); |
|
239 | - }else{ |
|
237 | + if (!is_null($studentClass)) { |
|
238 | + return array_search(str_replace($educationGrade['name'], $nextGrade->name, $studentClass->name), array_column($classes, 'name')); |
|
239 | + }else { |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param $count |
250 | 250 | * @param $params |
251 | 251 | */ |
252 | - public function assingeToClasses($student,$count,$params){ |
|
252 | + public function assingeToClasses($student, $count, $params) { |
|
253 | 253 | $academicPeriod = $params[0]; |
254 | 254 | $educationGrade = $params[1]; |
255 | 255 | $nextGrade = $params[2]; |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | $status = $params[4]; |
258 | 258 | |
259 | 259 | |
260 | - $class = $this->getStudentClass($student,$educationGrade,$nextGrade,$classes); |
|
261 | - if(is_numeric($class)){ |
|
260 | + $class = $this->getStudentClass($student, $educationGrade, $nextGrade, $classes); |
|
261 | + if (is_numeric($class)) { |
|
262 | 262 | $class = $classes[$class]; |
263 | 263 | |
264 | - if(count($classes) == 1){ |
|
264 | + if (count($classes) == 1) { |
|
265 | 265 | $class = $classes[0]; |
266 | 266 | } |
267 | 267 | |
268 | - if(!is_null($class)){ |
|
268 | + if (!is_null($class)) { |
|
269 | 269 | |
270 | 270 | $studentObj = [ |
271 | 271 | 'student_id' => $student['student_id'], |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | 'student_status_id' => $status, |
277 | 277 | 'created_user_id' => $student['created_user_id'] |
278 | 278 | ]; |
279 | - if(!$this->institution_class_students->isDuplicated($studentObj)){ |
|
279 | + if (!$this->institution_class_students->isDuplicated($studentObj)) { |
|
280 | 280 | $this->institution_class_students->create($studentObj); |
281 | 281 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
282 | - $output->writeln('----------------- '. $student['student_id']. 'to ' . $class['name']); |
|
283 | - }else{ |
|
284 | - $this->institution_class_students->where('id',(string)$student['id'])->update($studentObj); |
|
282 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
283 | + }else { |
|
284 | + $this->institution_class_students->where('id', (string) $student['id'])->update($studentObj); |
|
285 | 285 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
286 | - $output->writeln('----------------- '. $student['student_id']. 'to ' . $class['name']); |
|
286 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | if (!empty($isAvailableforPromotion)) { |
82 | 82 | $this->process($institutionGrade,$nextGrade,$year,1); |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | $this->process($institutionGrade,$nextGrade,$year,3); |
85 | 85 | } |
86 | 86 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | array_walk($studentListToPromote,array($this,'assingeToClasses'),$params); |
128 | 128 | array_walk($parallelClasses,array($this,'updateStudentCount')); |
129 | 129 | } |
130 | - }catch (\Exception $e){ |
|
130 | + } catch (\Exception $e){ |
|
131 | 131 | dd($e); |
132 | 132 | Log::error($e->getMessage()); |
133 | 133 | } |
@@ -166,20 +166,20 @@ discard block |
||
166 | 166 | // promote parallel classes |
167 | 167 | $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$nextGradeObj->toArray(),1); |
168 | 168 | return 1; |
169 | - }elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())){ |
|
169 | + } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())){ |
|
170 | 170 | // promote pool promotion |
171 | 171 | $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],1); |
172 | 172 | return 2; |
173 | - }elseif(($nextGradeObj->count() > 1) && $currentGradeObj->count() == $nextGradeObj->count()){ |
|
173 | + } elseif(($nextGradeObj->count() > 1) && $currentGradeObj->count() == $nextGradeObj->count()){ |
|
174 | 174 | // Promote matching class name with previous class |
175 | 175 | $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$nextGradeObj->toArray(),1); |
176 | 176 | return 1; |
177 | - }else{ |
|
177 | + } else{ |
|
178 | 178 | // default pool promotion |
179 | 179 | $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],1); |
180 | 180 | return 2; |
181 | 181 | } |
182 | - }else{ |
|
182 | + } else{ |
|
183 | 183 | // default pool promotion |
184 | 184 | $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],3); |
185 | 185 | return 2; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
217 | 217 | $output->writeln('----------------- '. $student['admission_id'] . ' to ' . $studentData['education_grade_id']); |
218 | 218 | |
219 | - }catch (\Exception $e){ |
|
219 | + } catch (\Exception $e){ |
|
220 | 220 | dd($e); |
221 | 221 | Log::error($e->getMessage()); |
222 | 222 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $studentClass = $this->institution_class_students->getStudentNewClass($student); |
237 | 237 | if(!is_null($studentClass)){ |
238 | 238 | return array_search(str_replace($educationGrade['name'],$nextGrade->name,$studentClass->name),array_column($classes,'name')); |
239 | - }else{ |
|
239 | + } else{ |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $this->institution_class_students->create($studentObj); |
281 | 281 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
282 | 282 | $output->writeln('----------------- '. $student['student_id']. 'to ' . $class['name']); |
283 | - }else{ |
|
283 | + } else{ |
|
284 | 284 | $this->institution_class_students->where('id',(string)$student['id'])->update($studentObj); |
285 | 285 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
286 | 286 | $output->writeln('----------------- '. $student['student_id']. 'to ' . $class['name']); |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | $this->start_time = microtime(TRUE); |
47 | 47 | ini_set('memory_limit', '2048M'); |
48 | 48 | $students = $this->students->query() |
49 | - ->where('is_student',1) |
|
49 | + ->where('is_student', 1) |
|
50 | 50 | ->limit(100000) |
51 | 51 | ->offset($this->argument('offset')) |
52 | 52 | ->get()->toArray(); |
53 | 53 | $this->output->writeln('no of students'.count($students)); |
54 | 54 | $this->output->writeln('Update started'); |
55 | - array_walk($students,array($this,'updateNewUUID')); |
|
55 | + array_walk($students, array($this, 'updateNewUUID')); |
|
56 | 56 | $this->end_time = microtime(TRUE); |
57 | 57 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
58 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
58 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
59 | 59 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
60 | 60 | } |
61 | 61 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * @param $student |
65 | 65 | * @throws \Exception |
66 | 66 | */ |
67 | - public function updateNewUUID($student){ |
|
68 | - if(!MoeUuid::isValidMoeUuid(3)){ |
|
67 | + public function updateNewUUID($student) { |
|
68 | + if (!MoeUuid::isValidMoeUuid(3)) { |
|
69 | 69 | $newId = MoeUuid::getUniqueAlphanumeric(3); |
70 | 70 | $this->output->writeln('Updating student:'.$student['id']); |
71 | - Security_user::query()->where('id',$student['id']) |
|
72 | - ->update(['openemis_no' => $newId , 'username' => str_replace('-','',$newId)]); |
|
71 | + Security_user::query()->where('id', $student['id']) |
|
72 | + ->update(['openemis_no' => $newId, 'username' => str_replace('-', '', $newId)]); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -45,19 +45,19 @@ discard block |
||
45 | 45 | { |
46 | 46 | $files = $this->getFiles(); |
47 | 47 | try { |
48 | - if(!empty($files)){ |
|
49 | - array_walk($files,array($this,'process')); |
|
48 | + if (!empty($files)) { |
|
49 | + array_walk($files, array($this, 'process')); |
|
50 | 50 | unset($files); |
51 | 51 | exit(); |
52 | 52 | |
53 | - }else{ |
|
53 | + }else { |
|
54 | 54 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
55 | 55 | $output->writeln('No files found,Waiting for files'); |
56 | 56 | exit(); |
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | - }catch (Exception $e){ |
|
60 | + }catch (Exception $e) { |
|
61 | 61 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
62 | 62 | $output->writeln($e); |
63 | 63 | sleep(300); |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | |
68 | 68 | } |
69 | 69 | |
70 | - protected function getFiles(){ |
|
70 | + protected function getFiles() { |
|
71 | 71 | $files = Upload::where('is_processed', '=', 3) |
72 | - ->where('is_email_sent','=',0) |
|
72 | + ->where('is_email_sent', '=', 0) |
|
73 | 73 | ->where('updated_at', '<=', Carbon::now()->tz('Asia/Colombo')->subHours(3)) |
74 | 74 | ->limit(50) |
75 | 75 | ->get()->toArray(); |
76 | 76 | return $files; |
77 | 77 | } |
78 | 78 | |
79 | - protected function process($file){ |
|
79 | + protected function process($file) { |
|
80 | 80 | $time = Carbon::now()->tz('Asia/Colombo'); |
81 | 81 | $this->processSheet($file); |
82 | 82 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
83 | 83 | $now = Carbon::now()->tz('Asia/Colombo'); |
84 | - $output->writeln('=============== Time taken to batch ' .$now->diffInMinutes($time)); |
|
84 | + $output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time)); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - protected function processSheet($file){ |
|
88 | + protected function processSheet($file) { |
|
89 | 89 | $this->startTime = Carbon::now()->tz('Asia/Colombo'); |
90 | 90 | $user = User::find($file['security_user_id']); |
91 | 91 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | Mail::to($user->email)->send(new TerminatedReport($file)); |
96 | 96 | DB::table('uploads') |
97 | 97 | ->where('id', $file['id']) |
98 | - ->update(['is_processed' => 3, 'is_email_sent' => 1,'updated_at' => now()]); |
|
99 | - } else { |
|
98 | + ->update(['is_processed' => 3, 'is_email_sent' => 1, 'updated_at' => now()]); |
|
99 | + }else { |
|
100 | 100 | exit(); |
101 | 101 | } |
102 | 102 | } |
@@ -50,14 +50,14 @@ |
||
50 | 50 | unset($files); |
51 | 51 | exit(); |
52 | 52 | |
53 | - }else{ |
|
53 | + } else{ |
|
54 | 54 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
55 | 55 | $output->writeln('No files found,Waiting for files'); |
56 | 56 | exit(); |
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | - }catch (Exception $e){ |
|
60 | + } catch (Exception $e){ |
|
61 | 61 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
62 | 62 | $output->writeln($e); |
63 | 63 | sleep(300); |