@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public static function boot() |
72 | 72 | { |
73 | 73 | parent::boot(); |
74 | - self::creating(function ($model) { |
|
74 | + self::creating(function($model) { |
|
75 | 75 | $model->id = (string) Uuid::generate(4); |
76 | 76 | $model->created = now(); |
77 | 77 | }); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public static function createExaminationData($student, $admissionInfo) |
144 | 144 | { |
145 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
145 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
146 | 146 | try { |
147 | 147 | self::create([ |
148 | 148 | 'id' => (string) Uuid::generate(4), |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'created' => now(), |
168 | 168 | 'created_user_id' => 1 |
169 | 169 | ]); |
170 | - } catch (\Throwable $th) { |
|
170 | + }catch (\Throwable $th) { |
|
171 | 171 | Log::error($th); |
172 | 172 | } |
173 | 173 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public static function updateExaminationData($student, $admissionInfo) |
183 | 183 | { |
184 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
184 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
185 | 185 | try { |
186 | 186 | self::where([ |
187 | 187 | 'student_id' => $student['student_id'], |
@@ -202,50 +202,50 @@ discard block |
||
202 | 202 | 'modified_user_id' => 1 |
203 | 203 | ] |
204 | 204 | ); |
205 | - } catch (\Throwable $th) { |
|
205 | + }catch (\Throwable $th) { |
|
206 | 206 | Log::error($th); |
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - public static function updateStudentArea(array $student){ |
|
211 | - $father = Student_guardian::where('student_id',$student['student_id']) |
|
212 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
213 | - ->where('guardian_relation_id',1) |
|
210 | + public static function updateStudentArea(array $student) { |
|
211 | + $father = Student_guardian::where('student_id', $student['student_id']) |
|
212 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
213 | + ->where('guardian_relation_id', 1) |
|
214 | 214 | ->get()->first(); |
215 | 215 | |
216 | - $mother = Student_guardian::where('student_id',$student['student_id']) |
|
217 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
218 | - ->where('guardian_relation_id',2) |
|
216 | + $mother = Student_guardian::where('student_id', $student['student_id']) |
|
217 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
218 | + ->where('guardian_relation_id', 2) |
|
219 | 219 | ->get()->first(); |
220 | 220 | |
221 | - $guardian = Student_guardian::where('student_id',$student['student_id']) |
|
222 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
223 | - ->where('guardian_relation_id',3) |
|
221 | + $guardian = Student_guardian::where('student_id', $student['student_id']) |
|
222 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
223 | + ->where('guardian_relation_id', 3) |
|
224 | 224 | ->get()->first(); |
225 | 225 | |
226 | - if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
|
227 | - Security_user::where('id',$student['student_id']) |
|
226 | + if (!is_null($father) && is_null($mother) && is_null($guardian)) { |
|
227 | + Security_user::where('id', $student['student_id']) |
|
228 | 228 | ->update(['address_area_id' => $father->address_area_id]); |
229 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
230 | - Security_user::where('id',$student['student_id']) |
|
229 | + }elseif (!is_null($mother) && (is_null($father) && is_null($guardian))) { |
|
230 | + Security_user::where('id', $student['student_id']) |
|
231 | 231 | ->update(['address_area_id' => $mother->address_area_id]); |
232 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
233 | - Security_user::where('id',$student['student_id']) |
|
232 | + }elseif (!is_null($guardian) && is_null($father) && is_null($mother)) { |
|
233 | + Security_user::where('id', $student['student_id']) |
|
234 | 234 | ->update(['address_area_id' => $guardian->address_area_id]); |
235 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
236 | - Security_user::where('id',$student['student_id']) |
|
235 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) { |
|
236 | + Security_user::where('id', $student['student_id']) |
|
237 | 237 | ->update(['address_area_id' => $mother->address_area_id]); |
238 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
239 | - Security_user::where('id',$student['student_id']) |
|
238 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) { |
|
239 | + Security_user::where('id', $student['student_id']) |
|
240 | 240 | ->update(['address_area_id' => $guardian->address_area_id]); |
241 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
242 | - Security_user::where('id',$student['student_id']) |
|
241 | + }elseif (!is_null($father) && $father->address == $student['address']) { |
|
242 | + Security_user::where('id', $student['student_id']) |
|
243 | 243 | ->update(['address_area_id' => $guardian->address_area_id]); |
244 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
245 | - Security_user::where('id',$student['student_id']) |
|
244 | + }elseif (!is_null($mother) && $mother->address == $student['address']) { |
|
245 | + Security_user::where('id', $student['student_id']) |
|
246 | 246 | ->update(['address_area_id' => $mother->address_area_id]); |
247 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
248 | - Security_user::where('id',$student['student_id']) |
|
247 | + }elseif (!is_null($guardian) && $guardian->address == $student['address']) { |
|
248 | + Security_user::where('id', $student['student_id']) |
|
249 | 249 | ->update(['address_area_id' => $guardian->address_area_id]); |
250 | 250 | } |
251 | 251 | } |
@@ -226,25 +226,25 @@ |
||
226 | 226 | if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
227 | 227 | Security_user::where('id',$student['student_id']) |
228 | 228 | ->update(['address_area_id' => $father->address_area_id]); |
229 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
229 | + } elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
230 | 230 | Security_user::where('id',$student['student_id']) |
231 | 231 | ->update(['address_area_id' => $mother->address_area_id]); |
232 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
232 | + } elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
233 | 233 | Security_user::where('id',$student['student_id']) |
234 | 234 | ->update(['address_area_id' => $guardian->address_area_id]); |
235 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
235 | + } elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
236 | 236 | Security_user::where('id',$student['student_id']) |
237 | 237 | ->update(['address_area_id' => $mother->address_area_id]); |
238 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
238 | + } elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
239 | 239 | Security_user::where('id',$student['student_id']) |
240 | 240 | ->update(['address_area_id' => $guardian->address_area_id]); |
241 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
241 | + } elseif(!is_null($father) && $father->address == $student['address']){ |
|
242 | 242 | Security_user::where('id',$student['student_id']) |
243 | 243 | ->update(['address_area_id' => $guardian->address_area_id]); |
244 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
244 | + } elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
245 | 245 | Security_user::where('id',$student['student_id']) |
246 | 246 | ->update(['address_area_id' => $mother->address_area_id]); |
247 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
247 | + } elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
248 | 248 | Security_user::where('id',$student['student_id']) |
249 | 249 | ->update(['address_area_id' => $guardian->address_area_id]); |
250 | 250 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function process($student) |
76 | 76 | { |
77 | - try{ |
|
77 | + try{ |
|
78 | 78 | $wrongStudentsClass = Institution_class_student::where('institution_id', $student['institution_id']) |
79 | 79 | ->whereRaw('institution_class_id not in (select id from institution_classes where institution_id ='.$student['institution_id'].' )') |
80 | 80 | ->orWhere('institution_class_id', 0) |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | array_walk($institutionClassStudent, array($this->class, 'updateClassCount')); |
143 | 143 | } |
144 | 144 | } |
145 | - }catch(\Exception $e){ |
|
145 | + }catch(\Exception $e){ |
|
146 | 146 | dd($e); |
147 | - } |
|
147 | + } |
|
148 | 148 | } |
149 | 149 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | |
52 | 52 | if ($this->argument('code') !== 'All') { |
53 | 53 | $institutions = Institution::where('code', $this->argument('code'))->get()->toArray(); |
54 | - processParallel(array($this,'processInstitution'),$institutions,$this->argument('max')); |
|
55 | - } else { |
|
54 | + processParallel(array($this, 'processInstitution'), $institutions, $this->argument('max')); |
|
55 | + }else { |
|
56 | 56 | $institutions = Institution::where('institution_status_id', 1)->get()->toArray(); |
57 | - processParallel(array($this,'processInstitution'),$institutions,$this->argument('max')); |
|
57 | + processParallel(array($this, 'processInstitution'), $institutions, $this->argument('max')); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | ->where('institutions.id', $institution['id']) |
66 | 66 | ->get()->toArray(); |
67 | 67 | if (count($students) > 0) { |
68 | - array_walk($students,array($this, 'process')); |
|
69 | - $this->output->writeln("institution :" .$institution['code']. ' cleaned'); |
|
70 | - } else { |
|
71 | - $this->output->writeln("all records are cleaned at :".$institution['code'] ); |
|
68 | + array_walk($students, array($this, 'process')); |
|
69 | + $this->output->writeln("institution :".$institution['code'].' cleaned'); |
|
70 | + }else { |
|
71 | + $this->output->writeln("all records are cleaned at :".$institution['code']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function process($student) |
76 | 76 | { |
77 | - try{ |
|
77 | + try { |
|
78 | 78 | $wrongStudentsClass = Institution_class_student::where('institution_id', $student['institution_id']) |
79 | 79 | ->whereRaw('institution_class_id not in (select id from institution_classes where institution_id ='.$student['institution_id'].' )') |
80 | 80 | ->orWhere('institution_class_id', 0) |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | array_walk($wrongStudentsClass, array($this->class, 'updateClassCount')); |
90 | 90 | |
91 | - $institutionClass = Institution_class::getGradeClasses($student['education_grade_id'], $student['institution_id']); |
|
91 | + $institutionClass = Institution_class::getGradeClasses($student['education_grade_id'], $student['institution_id']); |
|
92 | 92 | |
93 | 93 | if (count($institutionClass) == 1) { |
94 | 94 | $start_date = new Carbon($student['start_date']); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | array_walk($institutionClassStudent, array($this->class, 'updateClassCount')); |
143 | 143 | } |
144 | 144 | } |
145 | - }catch(\Exception $e){ |
|
145 | + }catch (\Exception $e) { |
|
146 | 146 | dd($e); |
147 | 147 | } |
148 | 148 | } |
@@ -142,7 +142,7 @@ |
||
142 | 142 | array_walk($institutionClassStudent, array($this->class, 'updateClassCount')); |
143 | 143 | } |
144 | 144 | } |
145 | - }catch(\Exception $e){ |
|
145 | + } catch(\Exception $e){ |
|
146 | 146 | dd($e); |
147 | 147 | } |
148 | 148 | } |
@@ -52,16 +52,16 @@ |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | public function delete(){ |
55 | - try{ |
|
56 | - DB::statement("UPDATE student_guardians t1 |
|
55 | + try{ |
|
56 | + DB::statement("UPDATE student_guardians t1 |
|
57 | 57 | INNER JOIN student_guardians t2 |
58 | 58 | set t1.deleted_at=now() |
59 | 59 | WHERE |
60 | 60 | t1.id > t2.id AND |
61 | 61 | t1.student_id = t2.student_id AND |
62 | 62 | t1.guardian_id = t2.guardian_id"); |
63 | - }catch(\Exception $e){ |
|
64 | - dd($e); |
|
65 | - } |
|
63 | + }catch(\Exception $e){ |
|
64 | + dd($e); |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | } |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | $this->output->writeln('############### Starting delete Duplication ################'); |
46 | 46 | Student_guardian::withTrashed()->restore(); |
47 | 47 | $this->delete(); |
48 | - $this->end_time = microtime(TRUE); |
|
49 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
50 | - } catch (\Throwable $th) { |
|
48 | + $this->end_time = microtime(TRUE); |
|
49 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
50 | + }catch (\Throwable $th) { |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - public function delete(){ |
|
55 | - try{ |
|
54 | + public function delete() { |
|
55 | + try { |
|
56 | 56 | DB::statement("UPDATE student_guardians t1 |
57 | 57 | INNER JOIN student_guardians t2 |
58 | 58 | set t1.deleted_at=now() |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | t1.id > t2.id AND |
61 | 61 | t1.student_id = t2.student_id AND |
62 | 62 | t1.guardian_id = t2.guardian_id"); |
63 | - }catch(\Exception $e){ |
|
63 | + }catch (\Exception $e) { |
|
64 | 64 | dd($e); |
65 | 65 | } |
66 | 66 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | t1.id > t2.id AND |
61 | 61 | t1.student_id = t2.student_id AND |
62 | 62 | t1.guardian_id = t2.guardian_id"); |
63 | - }catch(\Exception $e){ |
|
63 | + } catch(\Exception $e){ |
|
64 | 64 | dd($e); |
65 | 65 | } |
66 | 66 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | if(count($shift) > 0){ |
67 | 67 | // processParallel($function,$shift, $this->argument('max'),$params); |
68 | 68 | array_walk($shift,$function,$params); |
69 | - }else{ |
|
69 | + } else{ |
|
70 | 70 | $this->output->writeln('Nothing to clone'); |
71 | 71 | } |
72 | 72 | $this->end_time = microtime(TRUE); |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
55 | 55 | $mode = $this->argument('mode') == 'AL' ? true : false; |
56 | 56 | $previousAcademicPeriodYear = $academicPeriod->order; |
57 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
58 | - $shift = $this->shifts->getShiftsToClone($previousAcademicPeriod->code,$this->argument(('max')),$mode); |
|
57 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
58 | + $shift = $this->shifts->getShiftsToClone($previousAcademicPeriod->code, $this->argument(('max')), $mode); |
|
59 | 59 | $params = [ |
60 | 60 | 'year' => $year, |
61 | 61 | 'academic_period' => $academicPeriod, |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | ]; |
65 | 65 | |
66 | 66 | $function = array($this->clone, 'process'); |
67 | - if(count($shift) > 0){ |
|
67 | + if (count($shift) > 0) { |
|
68 | 68 | // processParallel($function,$shift, $this->argument('max'),$params); |
69 | - array_walk($shift,$function,$params); |
|
70 | - }else{ |
|
69 | + array_walk($shift, $function, $params); |
|
70 | + }else { |
|
71 | 71 | $this->output->writeln('Nothing to clone'); |
72 | 72 | } |
73 | 73 | $this->end_time = microtime(TRUE); |
74 | 74 | |
75 | 75 | |
76 | 76 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
77 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
77 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
78 | 78 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
79 | 79 | } |
80 | 80 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct() |
32 | 32 | { |
33 | - $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
33 | + $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
34 | 34 | parent::__construct(); |
35 | 35 | } |
36 | 36 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function handle() |
43 | 43 | { |
44 | - $students = Security_user::where('is_student',true)->get()->toArray(); |
|
45 | - array_walk($students,array($this,'process')); |
|
44 | + $students = Security_user::where('is_student', true)->get()->toArray(); |
|
45 | + array_walk($students, array($this, 'process')); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function process($student){ |
|
48 | + public function process($student) { |
|
49 | 49 | $student['student_id'] = $student['id']; |
50 | 50 | Institution_student::updateStudentArea($student); |
51 | - $this->output->writeln('area updated for student:'. $student['openemis_no']) ; |
|
51 | + $this->output->writeln('area updated for student:'.$student['openemis_no']); |
|
52 | 52 | } |
53 | 53 | } |
@@ -48,16 +48,16 @@ |
||
48 | 48 | $year = $this->argument('year'); |
49 | 49 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
50 | 50 | $previousAcademicPeriodYear = $academicPeriod->order; |
51 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
51 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
52 | 52 | |
53 | 53 | $params = [ |
54 | 54 | 'academic_period' => $academicPeriod, |
55 | 55 | 'previous_academic_period' => $previousAcademicPeriod |
56 | 56 | ]; |
57 | 57 | |
58 | - if($year == '2019' || $year == '2018/19'){ |
|
58 | + if ($year == '2019' || $year == '2018/19') { |
|
59 | 59 | die('Academic Year 2019 or earlier can`t be deleted'); |
60 | - }else{ |
|
60 | + }else { |
|
61 | 61 | $this->clone->cleanConfig($params); |
62 | 62 | } |
63 | 63 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | if($year == '2019' || $year == '2018/19'){ |
59 | 59 | die('Academic Year 2019 or earlier can`t be deleted'); |
60 | - }else{ |
|
60 | + } else{ |
|
61 | 61 | $this->clone->cleanConfig($params); |
62 | 62 | } |
63 | 63 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | public function array_walk($shift, $count, $params) |
42 | 42 | { |
43 | 43 | try{ |
44 | - DB::beginTransaction(); |
|
44 | + DB::beginTransaction(); |
|
45 | 45 | array_walk($shift, array($this, 'process'), $params); |
46 | 46 | DB::commit(); |
47 | 47 | }catch(\Exception $e){ |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | $this->academic_period = new Academic_period(); |
32 | 32 | $this->institution_classes = new Institution_class(); |
33 | 33 | $this->institution_class_subjects = new Institution_class_subject(); |
34 | - $this->institution_subjects = new Institution_subject(); |
|
34 | + $this->institution_subjects = new Institution_subject(); |
|
35 | 35 | $this->institution_grades = new Institution_grade(); |
36 | - $this->education_grade_subjects = new Education_grades_subject(); |
|
36 | + $this->education_grade_subjects = new Education_grades_subject(); |
|
37 | 37 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | public function array_walk($shift, $count, $params) |
42 | 42 | { |
43 | - try{ |
|
43 | + try { |
|
44 | 44 | DB::beginTransaction(); |
45 | 45 | array_walk($shift, array($this, 'process'), $params); |
46 | 46 | DB::commit(); |
47 | - }catch(\Exception $e){ |
|
48 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
47 | + }catch (\Exception $e) { |
|
48 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
49 | 49 | DB::rollBack(); |
50 | 50 | } |
51 | 51 | } |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | $this->shifts->where(['cloned' => $academicPeriod->code])->update(['cloned' => $params['previous_academic_period']['code']]); |
60 | 60 | $this->output->writeln('updated shifts'); |
61 | 61 | |
62 | - $classIds = $this->institution_classes->select('id')->where(['academic_period_id' => $academicPeriod->id])->get()->toArray(); |
|
62 | + $classIds = $this->institution_classes->select('id')->where(['academic_period_id' => $academicPeriod->id])->get()->toArray(); |
|
63 | 63 | $this->institution_classes->where(['academic_period_id' => $academicPeriod->id])->delete(); |
64 | 64 | $this->output->writeln('cleaned classes'); |
65 | 65 | |
66 | 66 | do { |
67 | 67 | $deleted = $this->institution_class_subjects->whereRaw("institution_class_id not in (select id from institution_classes where academic_period_id =".$academicPeriod->id." )")->limit(10000)->delete(); |
68 | 68 | $this->output->writeln('cleaned subjects'); |
69 | - }while($deleted > 0); |
|
69 | + } while ($deleted > 0); |
|
70 | 70 | |
71 | 71 | do { |
72 | - $deleted = $this->institution_subjects->where('academic_period_id', $academicPeriod->id)->limit(10000)->delete(); |
|
72 | + $deleted = $this->institution_subjects->where('academic_period_id', $academicPeriod->id)->limit(10000)->delete(); |
|
73 | 73 | $this->output->writeln('10000 institutions cleaned subjects'); |
74 | 74 | } while ($deleted > 0); |
75 | 75 | } |
76 | 76 | |
77 | 77 | public function process($shift, $count, $params) |
78 | 78 | { |
79 | - echo ('[' . getmypid() . ']This Process executed at' . date("F d, Y h:i:s A") . "\n"); |
|
79 | + echo ('['.getmypid().']This Process executed at'.date("F d, Y h:i:s A")."\n"); |
|
80 | 80 | $year = $params['year']; |
81 | 81 | $academicPeriod = $params['academic_period']; |
82 | 82 | $previousAcademicPeriod = $params['previous_academic_period']; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | |
95 | 95 | |
96 | 96 | if ($mode) { |
97 | - $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode); |
|
97 | + $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode); |
|
98 | 98 | try { |
99 | 99 | array_walk($institutionClasses, array($this, 'updateInstitutionClasses'), $params); |
100 | - $this->output->writeln('updating from ' . $shift['institution_id']); |
|
101 | - } catch (\Exception $e) { |
|
100 | + $this->output->writeln('updating from '.$shift['institution_id']); |
|
101 | + }catch (\Exception $e) { |
|
102 | 102 | Log::error($e->getMessage(), [$e]); |
103 | 103 | } |
104 | - } else { |
|
104 | + }else { |
|
105 | 105 | $institutionSubjects = $this->institution_grades->getGradeSubjects($shift['institution_id']); |
106 | 106 | try { |
107 | 107 | if ($data['created']) { |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | try { |
113 | 113 | array_walk($newInstitutionClasses, array($this, 'insertInstitutionClasses'), $params); |
114 | 114 | $this->output->writeln('##########################################################################################################################'); |
115 | - $this->output->writeln('updating from = ' . $shift['institution_id']); |
|
116 | - } catch (\Exception $e) { |
|
117 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
115 | + $this->output->writeln('updating from = '.$shift['institution_id']); |
|
116 | + }catch (\Exception $e) { |
|
117 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
118 | 118 | DB::rollBack(); |
119 | 119 | Log::error($e->getMessage(), [$e]); |
120 | 120 | } |
121 | - } else { |
|
122 | - $this->output->writeln('no classes found ' . $shift['institution_id']); |
|
121 | + }else { |
|
122 | + $this->output->writeln('no classes found '.$shift['institution_id']); |
|
123 | 123 | } |
124 | - } else { |
|
124 | + }else { |
|
125 | 125 | try { |
126 | 126 | $shift['id'] = $shiftId; |
127 | 127 | $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode); |
128 | 128 | array_walk($institutionClasses, array($this, 'updateInstitutionClasses'), $params); |
129 | 129 | $this->output->writeln('##########################################################################################################################'); |
130 | - $this->output->writeln('updating from ' . $shift['institution_id']); |
|
131 | - } catch (\Exception $e) { |
|
132 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
130 | + $this->output->writeln('updating from '.$shift['institution_id']); |
|
131 | + }catch (\Exception $e) { |
|
132 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
133 | 133 | DB::rollBack(); |
134 | 134 | Log::error($e->getMessage(), [$e]); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | DB::commit(); |
138 | - } catch (\Exception $e) { |
|
138 | + }catch (\Exception $e) { |
|
139 | 139 | Log::error($e->getMessage(), [$e]); |
140 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
140 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
141 | 141 | DB::rollBack(); |
142 | 142 | } |
143 | 143 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $subject['created'] = now(); |
157 | 157 | $subject['created_user_id'] = 1; |
158 | 158 | $this->institution_subjects->create($subject); |
159 | - } catch (\Exception $e) { |
|
159 | + }catch (\Exception $e) { |
|
160 | 160 | DB::rollBack(); |
161 | 161 | Log::error($e->getMessage(), [$e]); |
162 | 162 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'academic_period_id' => $params['academic_period_id'] |
186 | 186 | ]); |
187 | 187 | } |
188 | - } catch (\Exception $e) { |
|
188 | + }catch (\Exception $e) { |
|
189 | 189 | DB::rollBack(); |
190 | 190 | Log::error($e->getMessage(), [$e]); |
191 | 191 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | $class['created'] = now(); |
216 | 216 | $class['institution_shift_id'] = $param['shift_id']; |
217 | 217 | // $class['created_user_id'] = |
218 | - $this->output->writeln('Create class:' . $class['name']); |
|
219 | - $class = Institution_class::create($class); |
|
218 | + $this->output->writeln('Create class:'.$class['name']); |
|
219 | + $class = Institution_class::create($class); |
|
220 | 220 | $institutionClassGrdaeObj['institution_class_id'] = $class->id; |
221 | 221 | $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae; |
222 | 222 | $institutionClassGrdaeObj['created_user_id'] = $class['created_user_id']; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | ->toArray(); |
229 | 229 | $params['class'] = $class; |
230 | 230 | $this->insertInstitutionClassSubjects($institutionSubjects, $class); |
231 | - } catch (\Exception $e) { |
|
231 | + }catch (\Exception $e) { |
|
232 | 232 | DB::rollBack(); |
233 | 233 | Log::error($e->getMessage(), [$e]); |
234 | 234 | } |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | if (!empty($subjects)) { |
240 | 240 | try { |
241 | 241 | array_walk($subjects, array($this, 'insertClassSubjects'), $class); |
242 | - $this->output->writeln('updating subjects ' . $class->name); |
|
243 | - } catch (\Exception $e) { |
|
242 | + $this->output->writeln('updating subjects '.$class->name); |
|
243 | + }catch (\Exception $e) { |
|
244 | 244 | DB::rollBack(); |
245 | 245 | Log::error($e->getMessage(), [$e]); |
246 | 246 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | if (!$this->institution_class_subjects->isDuplicated($subjectobj)) { |
262 | 262 | $this->institution_class_subjects->create($subjectobj); |
263 | 263 | } |
264 | - } catch (\Exception $e) { |
|
264 | + }catch (\Exception $e) { |
|
265 | 265 | DB::rollBack(); |
266 | 266 | Log::error($e->getMessage(), [$e]); |
267 | 267 | } |
@@ -309,19 +309,19 @@ discard block |
||
309 | 309 | unset($shift['id']); |
310 | 310 | unset($shift['created']); |
311 | 311 | unset($shift['modified']); |
312 | - $shift = $this->shifts->create((array)$shift); |
|
312 | + $shift = $this->shifts->create((array) $shift); |
|
313 | 313 | $data = [ |
314 | 314 | 'shift_id' => $shift->id, |
315 | 315 | 'created' => true |
316 | 316 | ]; |
317 | - } else { |
|
317 | + }else { |
|
318 | 318 | $data = [ |
319 | 319 | 'shift_id' => $exist->id, |
320 | 320 | 'created' => false |
321 | 321 | ]; |
322 | 322 | }; |
323 | 323 | return $data; |
324 | - } catch (\Exception $e) { |
|
324 | + }catch (\Exception $e) { |
|
325 | 325 | DB::rollBack(); |
326 | 326 | } |
327 | 327 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | DB::beginTransaction(); |
45 | 45 | array_walk($shift, array($this, 'process'), $params); |
46 | 46 | DB::commit(); |
47 | - }catch(\Exception $e){ |
|
47 | + } catch(\Exception $e){ |
|
48 | 48 | $this->output->writeln('Terminating ' . $shift['institution_id']); |
49 | 49 | DB::rollBack(); |
50 | 50 | } |
@@ -48,21 +48,21 @@ |
||
48 | 48 | $mode = $this->argument('mode'); |
49 | 49 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
50 | 50 | $previousAcademicPeriodYear = $academicPeriod->order; |
51 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
52 | - $institutions = $this->instituion_grade->getInstitutionGradeList($previousAcademicPeriod->code,$limit,$mode); |
|
51 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
52 | + $institutions = $this->instituion_grade->getInstitutionGradeList($previousAcademicPeriod->code, $limit, $mode); |
|
53 | 53 | $params = [ |
54 | 54 | 'year' => $year, |
55 | 55 | 'mode'=> $mode |
56 | 56 | ]; |
57 | - if(in_array($mode,['AL','1-5','SP','6-11'])){ |
|
58 | - array_walk($institutions,array($this,'callPromotion'),$params); |
|
59 | - }else{ |
|
57 | + if (in_array($mode, ['AL', '1-5', 'SP', '6-11'])) { |
|
58 | + array_walk($institutions, array($this, 'callPromotion'), $params); |
|
59 | + }else { |
|
60 | 60 | die('The give mode not support'); |
61 | 61 | } |
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | - protected function callPromotion($institution,$count,$params){ |
|
66 | - $this->call('promote:students',['year' => $params['year'],'institution' => $institution['code'],'mode' => $params['mode'] ]); |
|
65 | + protected function callPromotion($institution, $count, $params) { |
|
66 | + $this->call('promote:students', ['year' => $params['year'], 'institution' => $institution['code'], 'mode' => $params['mode']]); |
|
67 | 67 | } |
68 | 68 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | ]; |
57 | 57 | if(in_array($mode,['AL','1-5','SP','6-11'])){ |
58 | 58 | array_walk($institutions,array($this,'callPromotion'),$params); |
59 | - }else{ |
|
59 | + } else{ |
|
60 | 60 | die('The give mode not support'); |
61 | 61 | } |
62 | 62 |
@@ -65,15 +65,15 @@ |
||
65 | 65 | $institution = $this->argument('institution'); |
66 | 66 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
67 | 67 | $previousAcademicPeriodYear = $academicPeriod->order; |
68 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
68 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
69 | 69 | $mode = $this->argument('mode'); |
70 | - $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($previousAcademicPeriod->code,$institution,$mode); |
|
70 | + $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($previousAcademicPeriod->code, $institution, $mode); |
|
71 | 71 | $output->writeln('Start promoting:'.$institution); |
72 | 72 | $params = [ |
73 | 73 | 'academicPeriod' => $academicPeriod, |
74 | 74 | 'previousAcademicPeriod' => $previousAcademicPeriod |
75 | 75 | ]; |
76 | - (new BulkPromotion())->callback($institutionGrade,$params); |
|
76 | + (new BulkPromotion())->callback($institutionGrade, $params); |
|
77 | 77 | $output->writeln('Finished promoting:'.$institution); |
78 | 78 | } |
79 | 79 | } |