@@ -45,7 +45,7 @@ |
||
45 | 45 | public function build() |
46 | 46 | { |
47 | 47 | return $this->view('emails.mail') |
48 | - ->from($this->from_address,$this->from_name) |
|
48 | + ->from($this->from_address, $this->from_name) |
|
49 | 49 | ->to($this->user->email) |
50 | 50 | ->subject($this->subject) |
51 | 51 | ->with($this->with); |
@@ -100,58 +100,58 @@ |
||
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; |
@@ -62,7 +62,7 @@ discard block |
||
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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -165,10 +165,10 @@ discard block |
||
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 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 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 | } |
@@ -190,10 +190,10 @@ discard block |
||
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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -51,48 +51,48 @@ discard block |
||
51 | 51 | 'id' => $this->argument('institution') |
52 | 52 | ])->first(); |
53 | 53 | |
54 | - if(!is_null($institution)){ |
|
54 | + if (!is_null($institution)) { |
|
55 | 55 | try { |
56 | - $this->info('adding missing students to the admission ' . $institution->name); |
|
56 | + $this->info('adding missing students to the admission '.$institution->name); |
|
57 | 57 | $allApprovedStudents = Institution_student_admission::where([ |
58 | 58 | 'status_id' => 124, |
59 | 59 | 'institution_id' => $institution->id |
60 | 60 | ])->get()->toArray(); |
61 | 61 | $allApprovedStudents = array_chunk($allApprovedStudents, 50); |
62 | 62 | array_walk($allApprovedStudents, array($this, 'addStudents')); |
63 | - } catch (\Exception $e) { |
|
63 | + }catch (\Exception $e) { |
|
64 | 64 | Log::error($e); |
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - protected function addStudents($students){ |
|
70 | - array_walk($students,array($this,'addStudent')); |
|
69 | + protected function addStudents($students) { |
|
70 | + array_walk($students, array($this, 'addStudent')); |
|
71 | 71 | } |
72 | 72 | |
73 | - protected function addStudent($student){ |
|
73 | + protected function addStudent($student) { |
|
74 | 74 | // dd(Institution_class_student::isDuplicated($student)); |
75 | 75 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
76 | 76 | sleep(1); |
77 | - if(!(Institution_class_student::isDuplicated($student) > 0)){ |
|
77 | + if (!(Institution_class_student::isDuplicated($student) > 0)) { |
|
78 | 78 | $this->count += 1; |
79 | - $this->student = $student ; |
|
80 | - try{ |
|
79 | + $this->student = $student; |
|
80 | + try { |
|
81 | 81 | Institution_student::create([ |
82 | 82 | 'student_status_id' => 1, |
83 | 83 | 'student_id' => $student['student_id'], |
84 | 84 | 'education_grade_id' => $student['education_grade_id'], |
85 | 85 | 'academic_period_id' => $student['academic_period_id'], |
86 | 86 | 'start_date' => $student['start_date'], |
87 | - 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['start_date'])->year , // $student['start_date']->format('Y'), |
|
87 | + 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['start_date'])->year, // $student['start_date']->format('Y'), |
|
88 | 88 | 'end_date' => $student['end_date'], |
89 | - 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['end_date'])->year , //$student['end_date']->format('Y'), |
|
89 | + 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['end_date'])->year, //$student['end_date']->format('Y'), |
|
90 | 90 | 'institution_id' => $student['institution_id'], |
91 | 91 | 'admission_id' => $student['admission_id'], |
92 | 92 | 'created_user_id' => $student['created_user_id'], |
93 | 93 | ]); |
94 | 94 | |
95 | - if(!is_null($student['institution_class_id'])){ |
|
95 | + if (!is_null($student['institution_class_id'])) { |
|
96 | 96 | Institution_class_student::create([ |
97 | 97 | 'student_id' => $student['student_id'], |
98 | 98 | 'institution_class_id' => $student['institution_class_id'], |
@@ -109,23 +109,23 @@ discard block |
||
109 | 109 | # # |
110 | 110 | ####################################################' ); |
111 | 111 | // $output->writeln(); |
112 | - }catch (\Exception $e){ |
|
112 | + }catch (\Exception $e) { |
|
113 | 113 | // echo $e->getMessage(); |
114 | - $output->writeln( $e->getMessage()); |
|
114 | + $output->writeln($e->getMessage()); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | |
120 | - protected function setSubjects($student){ |
|
120 | + protected function setSubjects($student) { |
|
121 | 121 | $allSubjects = Institution_class_subject::getMandetorySubjects($student['institution_class_id']); |
122 | 122 | |
123 | 123 | if (!empty($allSubjects)) { |
124 | 124 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); |
125 | 125 | $this->student = $student; |
126 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); |
|
126 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); |
|
127 | 127 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
128 | - array_walk($allSubjects,array($this,'insertSubject')); |
|
128 | + array_walk($allSubjects, array($this, 'insertSubject')); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | unset($allSubjects); |
@@ -109,7 +109,7 @@ |
||
109 | 109 | # # |
110 | 110 | ####################################################' ); |
111 | 111 | // $output->writeln(); |
112 | - }catch (\Exception $e){ |
|
112 | + } catch (\Exception $e){ |
|
113 | 113 | // echo $e->getMessage(); |
114 | 114 | $output->writeln( $e->getMessage()); |
115 | 115 | } |
@@ -72,33 +72,33 @@ discard block |
||
72 | 72 | 'previous_academic_period' => $previousAcademicPeriod |
73 | 73 | ]; |
74 | 74 | // dd($shift); |
75 | - array_walk($shift,array($this,'process'),$params); |
|
75 | + array_walk($shift, array($this, 'process'), $params); |
|
76 | 76 | $this->end_time = microtime(TRUE); |
77 | 77 | |
78 | 78 | |
79 | 79 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
80 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
80 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
81 | 81 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | - public function array_walk($shift,$count,$params){ |
|
86 | - array_walk($shift,array($this,'process'),$params); |
|
85 | + public function array_walk($shift, $count, $params) { |
|
86 | + array_walk($shift, array($this, 'process'), $params); |
|
87 | 87 | } |
88 | 88 | |
89 | - public function process($shift,$count,$params){ |
|
89 | + public function process($shift, $count, $params) { |
|
90 | 90 | $year = $params['year']; |
91 | 91 | $academicPeriod = $params['academic_period']; |
92 | 92 | $previousAcademicPeriod = $params['previous_academic_period']; |
93 | 93 | // DB::beginTransaction(); |
94 | - try{ |
|
94 | + try { |
|
95 | 95 | $shiftId = $this->updateShifts($year, $shift); |
96 | 96 | $institutionClasses = $this->institution_classes->getShiftClasses($shift['id']); |
97 | 97 | $institutionSubjects = $this->education_grade_subjects->getInstitutionSubjects($shift['institution_id']); |
98 | - array_walk($institutionSubjects , array($this,'insertInstitutionSubjects'),$academicPeriod); |
|
99 | - if (!empty($institutionClasses) && !is_null($shiftId) && !is_null($academicPeriod) ) { |
|
98 | + array_walk($institutionSubjects, array($this, 'insertInstitutionSubjects'), $academicPeriod); |
|
99 | + if (!empty($institutionClasses) && !is_null($shiftId) && !is_null($academicPeriod)) { |
|
100 | 100 | |
101 | - $newInstitutionClasses = $this->generateNewClass($institutionClasses,$shiftId,$academicPeriod->id); |
|
101 | + $newInstitutionClasses = $this->generateNewClass($institutionClasses, $shiftId, $academicPeriod->id); |
|
102 | 102 | |
103 | 103 | $params = [ |
104 | 104 | 'previous_academic_period_id' => $previousAcademicPeriod->id, |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | 'shift_id' =>$shiftId |
107 | 107 | ]; |
108 | 108 | |
109 | - try{ |
|
110 | - array_walk($newInstitutionClasses,array($this,'insertInstitutionClasses'),$params); |
|
109 | + try { |
|
110 | + array_walk($newInstitutionClasses, array($this, 'insertInstitutionClasses'), $params); |
|
111 | 111 | $newInstitutionClasses = $this->institution_classes->getShiftClasses($shiftId); |
112 | 112 | $this->output->writeln('##########################################################################################################################'); |
113 | - $this->output->writeln('updating from '. $shiftId); |
|
113 | + $this->output->writeln('updating from '.$shiftId); |
|
114 | 114 | |
115 | - }catch (\Exception $e){ |
|
116 | - Log::error($e->getMessage(),[$e]); |
|
115 | + }catch (\Exception $e) { |
|
116 | + Log::error($e->getMessage(), [$e]); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | // DB::commit(); |
120 | - }catch (\Exception $e){ |
|
120 | + }catch (\Exception $e) { |
|
121 | 121 | // DB::rollBack(); |
122 | - Log::error($e->getMessage(),[$e]); |
|
122 | + Log::error($e->getMessage(), [$e]); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -129,31 +129,31 @@ discard block |
||
129 | 129 | * @param $count |
130 | 130 | * @param $academicPeriod |
131 | 131 | */ |
132 | - public function insertInstitutionSubjects($subjects, $count,$academicPeriod){ |
|
133 | - try{ |
|
132 | + public function insertInstitutionSubjects($subjects, $count, $academicPeriod) { |
|
133 | + try { |
|
134 | 134 | $subjects['academic_period_id'] = $academicPeriod->id; |
135 | 135 | $subjects['created'] = now(); |
136 | 136 | unset($subjects['total_male_students']); |
137 | 137 | unset($subjects['total_female_students']); |
138 | 138 | unset($subjects['id']); |
139 | 139 | $classSubject = Institution_subject::create($subjects); |
140 | - }catch (\Exception $e){ |
|
141 | - Log::error($e->getMessage(),[$e]); |
|
140 | + }catch (\Exception $e) { |
|
141 | + Log::error($e->getMessage(), [$e]); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | - public function insertInstitutionClasses($class,$count,$param){ |
|
147 | - try{ |
|
146 | + public function insertInstitutionClasses($class, $count, $param) { |
|
147 | + try { |
|
148 | 148 | |
149 | 149 | $academicPeriod = $param['academic_period_id']; |
150 | 150 | $educationGrdae = $class['education_grade_id']; |
151 | 151 | |
152 | 152 | $classId = $class['id']; |
153 | 153 | unset($class['id']); |
154 | - $institutionSubjects = Institution_subject::query()->where('education_grade_id',$class['education_grade_id']) |
|
155 | - ->where('institution_id',$class['institution_id']) |
|
156 | - ->where('academic_period_id',$academicPeriod)->get()->toArray(); |
|
154 | + $institutionSubjects = Institution_subject::query()->where('education_grade_id', $class['education_grade_id']) |
|
155 | + ->where('institution_id', $class['institution_id']) |
|
156 | + ->where('academic_period_id', $academicPeriod)->get()->toArray(); |
|
157 | 157 | $params = [ |
158 | 158 | 'class'=>$class, |
159 | 159 | 'subjects'=>$institutionSubjects, |
@@ -166,38 +166,38 @@ discard block |
||
166 | 166 | $class['no_of_students'] = $noOfStudents; |
167 | 167 | $class['created'] = now(); |
168 | 168 | $class['institution_shift_id'] = $param['shift_id']; |
169 | - $this->output->writeln('Create class:'. $class['name']); |
|
169 | + $this->output->writeln('Create class:'.$class['name']); |
|
170 | 170 | $class = Institution_class::create($class); |
171 | 171 | $institutionClassGrdaeObj['institution_class_id'] = $class->id; |
172 | 172 | $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae; |
173 | 173 | Institution_class_grade::create($institutionClassGrdaeObj); |
174 | - $institutionSubjects = Institution_subject::query()->where('education_grade_id',$educationGrdae) |
|
175 | - ->where('institution_id',$class->institution_id) |
|
176 | - ->where('academic_period_id',$academicPeriod) |
|
174 | + $institutionSubjects = Institution_subject::query()->where('education_grade_id', $educationGrdae) |
|
175 | + ->where('institution_id', $class->institution_id) |
|
176 | + ->where('academic_period_id', $academicPeriod) |
|
177 | 177 | ->groupBy('education_subject_id') |
178 | 178 | ->get() |
179 | 179 | ->toArray(); |
180 | 180 | $params['class'] = $class; |
181 | - $this->insertInstitutionClassSubjects($institutionSubjects,$class); |
|
181 | + $this->insertInstitutionClassSubjects($institutionSubjects, $class); |
|
182 | 182 | // array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params); |
183 | - }catch (\Exception $e){ |
|
184 | - Log::error($e->getMessage(),[$e]); |
|
183 | + }catch (\Exception $e) { |
|
184 | + Log::error($e->getMessage(), [$e]); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - public function insertInstitutionClassSubjects($subjects,$class){ |
|
189 | - if(!empty($subjects)){ |
|
190 | - try{ |
|
191 | - array_walk($subjects,array($this,'insertClassSubjects'),$class); |
|
192 | - $this->output->writeln('updating subjects '. $class->name); |
|
193 | - }catch (\Exception $e){ |
|
194 | - Log::error($e->getMessage(),[$e]); |
|
188 | + public function insertInstitutionClassSubjects($subjects, $class) { |
|
189 | + if (!empty($subjects)) { |
|
190 | + try { |
|
191 | + array_walk($subjects, array($this, 'insertClassSubjects'), $class); |
|
192 | + $this->output->writeln('updating subjects '.$class->name); |
|
193 | + }catch (\Exception $e) { |
|
194 | + Log::error($e->getMessage(), [$e]); |
|
195 | 195 | } |
196 | 196 | }; |
197 | 197 | } |
198 | 198 | |
199 | - public function insertClassSubjects($subject,$count,$newClassId){ |
|
200 | - try{ |
|
199 | + public function insertClassSubjects($subject, $count, $newClassId) { |
|
200 | + try { |
|
201 | 201 | $subjectobj['status'] = 1; |
202 | 202 | $subjectobj['created_user_id'] = 1; |
203 | 203 | $subjectobj['created'] = now(); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | $subjectobj['institution_class_id'] = $newClassId->id; |
206 | 206 | $subjectobj['institution_subject_id'] = $subject['id']; |
207 | 207 | |
208 | - if(!$this->institution_class_subjects->isDuplicated($subjectobj)){ |
|
208 | + if (!$this->institution_class_subjects->isDuplicated($subjectobj)) { |
|
209 | 209 | $this->institution_class_subjects->create($subjectobj); |
210 | 210 | } |
211 | - }catch (\Exception $e){ |
|
212 | - Log::error($e->getMessage(),[$e]); |
|
211 | + }catch (\Exception $e) { |
|
212 | + Log::error($e->getMessage(), [$e]); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | $this->output->writeln('##########################################################################################################################'); |
113 | 113 | $this->output->writeln('updating from '. $shiftId); |
114 | 114 | |
115 | - }catch (\Exception $e){ |
|
115 | + } catch (\Exception $e){ |
|
116 | 116 | Log::error($e->getMessage(),[$e]); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | // DB::commit(); |
120 | - }catch (\Exception $e){ |
|
120 | + } catch (\Exception $e){ |
|
121 | 121 | // DB::rollBack(); |
122 | 122 | Log::error($e->getMessage(),[$e]); |
123 | 123 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | unset($subjects['total_female_students']); |
138 | 138 | unset($subjects['id']); |
139 | 139 | $classSubject = Institution_subject::create($subjects); |
140 | - }catch (\Exception $e){ |
|
140 | + } catch (\Exception $e){ |
|
141 | 141 | Log::error($e->getMessage(),[$e]); |
142 | 142 | } |
143 | 143 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $params['class'] = $class; |
181 | 181 | $this->insertInstitutionClassSubjects($institutionSubjects,$class); |
182 | 182 | // array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params); |
183 | - }catch (\Exception $e){ |
|
183 | + } catch (\Exception $e){ |
|
184 | 184 | Log::error($e->getMessage(),[$e]); |
185 | 185 | } |
186 | 186 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | try{ |
191 | 191 | array_walk($subjects,array($this,'insertClassSubjects'),$class); |
192 | 192 | $this->output->writeln('updating subjects '. $class->name); |
193 | - }catch (\Exception $e){ |
|
193 | + } catch (\Exception $e){ |
|
194 | 194 | Log::error($e->getMessage(),[$e]); |
195 | 195 | } |
196 | 196 | }; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if(!$this->institution_class_subjects->isDuplicated($subjectobj)){ |
209 | 209 | $this->institution_class_subjects->create($subjectobj); |
210 | 210 | } |
211 | - }catch (\Exception $e){ |
|
211 | + } catch (\Exception $e){ |
|
212 | 212 | Log::error($e->getMessage(),[$e]); |
213 | 213 | } |
214 | 214 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | |
288 | - protected function getSheetCount($file){ |
|
288 | + protected function getSheetCount($file) { |
|
289 | 289 | $objPHPExcel = $this->setReader($file); |
290 | 290 | return $objPHPExcel->getSheetCount(); |
291 | 291 | } |
@@ -297,205 +297,205 @@ discard block |
||
297 | 297 | * @param $sheet |
298 | 298 | * @param $column |
299 | 299 | */ |
300 | - protected function import($file, $sheet, $column){ |
|
300 | + protected function import($file, $sheet, $column) { |
|
301 | 301 | try { |
302 | 302 | ini_set('memory_limit', '2048M'); |
303 | 303 | $this->getFileSize($file); |
304 | 304 | $user = User::find($file['security_user_id']); |
305 | - $excelFile = '/sis-bulk-data-files/' . $file['filename']; |
|
306 | - $this->higestRow = $this->getHigestRow($file, $sheet,$column); |
|
307 | - switch ($sheet){ |
|
305 | + $excelFile = '/sis-bulk-data-files/'.$file['filename']; |
|
306 | + $this->higestRow = $this->getHigestRow($file, $sheet, $column); |
|
307 | + switch ($sheet) { |
|
308 | 308 | case 1; |
309 | - $this->output->writeln( 'Trying to insert Students'); |
|
310 | - if (($this->getSheetName($file,'Insert Students')) && $this->higestRow > 0) { // |
|
309 | + $this->output->writeln('Trying to insert Students'); |
|
310 | + if (($this->getSheetName($file, 'Insert Students')) && $this->higestRow > 0) { // |
|
311 | 311 | $import = new UsersImport($file); |
312 | - $import->import($excelFile,'local',$this->getSheetType($file['filename'])); |
|
312 | + $import->import($excelFile, 'local', $this->getSheetType($file['filename'])); |
|
313 | 313 | // Excel::import($import, $excelFile, 'local'); |
314 | 314 | DB::table('uploads') |
315 | 315 | ->where('id', $file['id']) |
316 | - ->update(['insert' => 1,'is_processed' => 1,'updated_at' => now()]); |
|
317 | - if($import->failures()->count() > 0){ |
|
318 | - self::writeErrors($import,$file,'Insert Students'); |
|
316 | + ->update(['insert' => 1, 'is_processed' => 1, 'updated_at' => now()]); |
|
317 | + if ($import->failures()->count() > 0) { |
|
318 | + self::writeErrors($import, $file, 'Insert Students'); |
|
319 | 319 | DB::table('uploads') |
320 | 320 | ->where('id', $file['id']) |
321 | - ->update(['insert' => 3,'updated_at' => now()]); |
|
322 | - $this->processFailedEmail($file,$user,'Fresh Student Data Upload:Partial Success '); |
|
323 | - $this->stdOut('Insert Students',$this->higestRow); |
|
324 | - } else{ |
|
325 | - $this->processSuccessEmail($file,$user,'Fresh Student Data Upload:Success '); |
|
326 | - $this->stdOut('Insert Students',$this->higestRow); |
|
321 | + ->update(['insert' => 3, 'updated_at' => now()]); |
|
322 | + $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Partial Success '); |
|
323 | + $this->stdOut('Insert Students', $this->higestRow); |
|
324 | + }else { |
|
325 | + $this->processSuccessEmail($file, $user, 'Fresh Student Data Upload:Success '); |
|
326 | + $this->stdOut('Insert Students', $this->higestRow); |
|
327 | 327 | } |
328 | - } else if(($this->getSheetName($file,'Insert Students')) && $this->higestRow > 0) { |
|
328 | + }else if (($this->getSheetName($file, 'Insert Students')) && $this->higestRow > 0) { |
|
329 | 329 | DB::table('uploads') |
330 | 330 | ->where('id', $file['id']) |
331 | 331 | ->update(['is_processed' => 2]); |
332 | - $this->processEmptyEmail($file,$user, 'Fresh Student Data Upload '); |
|
332 | + $this->processEmptyEmail($file, $user, 'Fresh Student Data Upload '); |
|
333 | 333 | } |
334 | 334 | break; |
335 | 335 | case 2; |
336 | - $this->output->writeln( 'Trying to update Students'); |
|
337 | - if (($this->getSheetName($file,'Update Students')) && $this->higestRow > 0) { |
|
336 | + $this->output->writeln('Trying to update Students'); |
|
337 | + if (($this->getSheetName($file, 'Update Students')) && $this->higestRow > 0) { |
|
338 | 338 | $import = new StudentUpdate($file); |
339 | - $import->import($excelFile,'local',$this->getSheetType($file['filename'])); |
|
339 | + $import->import($excelFile, 'local', $this->getSheetType($file['filename'])); |
|
340 | 340 | DB::table('uploads') |
341 | 341 | ->where('id', $file['id']) |
342 | - ->update(['update' => 1,'is_processed' => 1,'updated_at' => now()]); |
|
343 | - if($import->failures()->count() > 0){ |
|
344 | - self::writeErrors($import,$file,'Update Students'); |
|
342 | + ->update(['update' => 1, 'is_processed' => 1, 'updated_at' => now()]); |
|
343 | + if ($import->failures()->count() > 0) { |
|
344 | + self::writeErrors($import, $file, 'Update Students'); |
|
345 | 345 | DB::table('uploads') |
346 | 346 | ->where('id', $file['id']) |
347 | - ->update(['update' => 3,'is_processed' => 1,'updated_at' => now()]); |
|
348 | - $this->processFailedEmail($file,$user,'Existing Student Data Update:Partial Success '); |
|
349 | - $this->stdOut('Update Students',$this->higestRow); |
|
350 | - } else{ |
|
351 | - $this->processSuccessEmail($file,$user, 'Existing Student Data Update:Success '); |
|
352 | - $this->stdOut('Update Students',$this->higestRow); |
|
347 | + ->update(['update' => 3, 'is_processed' => 1, 'updated_at' => now()]); |
|
348 | + $this->processFailedEmail($file, $user, 'Existing Student Data Update:Partial Success '); |
|
349 | + $this->stdOut('Update Students', $this->higestRow); |
|
350 | + }else { |
|
351 | + $this->processSuccessEmail($file, $user, 'Existing Student Data Update:Success '); |
|
352 | + $this->stdOut('Update Students', $this->higestRow); |
|
353 | 353 | } |
354 | - } else if(($this->getSheetName($file,'Update Students')) && $this->higestRow == 0) { |
|
354 | + }else if (($this->getSheetName($file, 'Update Students')) && $this->higestRow == 0) { |
|
355 | 355 | DB::table('uploads') |
356 | 356 | ->where('id', $file['id']) |
357 | - ->update(['is_processed' => 2,'updated_at' => now()]); |
|
358 | - $this->processEmptyEmail($file,$user, 'Existing Student Data Update'); |
|
357 | + ->update(['is_processed' => 2, 'updated_at' => now()]); |
|
358 | + $this->processEmptyEmail($file, $user, 'Existing Student Data Update'); |
|
359 | 359 | } |
360 | 360 | break; |
361 | 361 | } |
362 | 362 | }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
363 | - $this->output->writeln( $e->getMessage()); |
|
364 | - if($sheet == 1){ |
|
365 | - self::writeErrors($e,$file,'Insert Students'); |
|
363 | + $this->output->writeln($e->getMessage()); |
|
364 | + if ($sheet == 1) { |
|
365 | + self::writeErrors($e, $file, 'Insert Students'); |
|
366 | 366 | DB::table('uploads') |
367 | 367 | ->where('id', $file['id']) |
368 | - ->update(['insert' => 2,'updated_at' => now()]); |
|
369 | - $this->processFailedEmail($file,$user,'Fresh Student Data Upload:Failed'); |
|
370 | - }else if($sheet == 2){ |
|
371 | - self::writeErrors($e,$file,'Update Students'); |
|
368 | + ->update(['insert' => 2, 'updated_at' => now()]); |
|
369 | + $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Failed'); |
|
370 | + }else if ($sheet == 2) { |
|
371 | + self::writeErrors($e, $file, 'Update Students'); |
|
372 | 372 | DB::table('uploads') |
373 | 373 | ->where('id', $file['id']) |
374 | - ->update(['update' => 2,'updated_at' => now()]); |
|
375 | - $this->processFailedEmail($file,$user, 'Existing Student Data Update:Failed'); |
|
374 | + ->update(['update' => 2, 'updated_at' => now()]); |
|
375 | + $this->processFailedEmail($file, $user, 'Existing Student Data Update:Failed'); |
|
376 | 376 | } |
377 | 377 | DB::table('uploads') |
378 | - ->where('id', $file['id']) |
|
379 | - ->update(['is_processed' =>2 , 'updated_at' => now()]); |
|
378 | + ->where('id', $file['id']) |
|
379 | + ->update(['is_processed' =>2, 'updated_at' => now()]); |
|
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | 383 | } |
384 | 384 | |
385 | - protected function processErrors($failure){ |
|
386 | - $error_mesg = implode(',',$failure->errors()); |
|
385 | + protected function processErrors($failure) { |
|
386 | + $error_mesg = implode(',', $failure->errors()); |
|
387 | 387 | $failure = [ |
388 | 388 | 'row'=> $failure->row(), |
389 | - 'errors' => [ $error_mesg], |
|
389 | + 'errors' => [$error_mesg], |
|
390 | 390 | 'attribute' => $failure->attribute() |
391 | 391 | ]; |
392 | 392 | return $failure; |
393 | 393 | |
394 | 394 | } |
395 | 395 | |
396 | - protected function getFileSize($file){ |
|
397 | - $excelFile = '/sis-bulk-data-files/' . $file['filename']; |
|
396 | + protected function getFileSize($file) { |
|
397 | + $excelFile = '/sis-bulk-data-files/'.$file['filename']; |
|
398 | 398 | $size = Storage::disk('local')->size($excelFile); |
399 | 399 | $user = User::find($file['security_user_id']); |
400 | - if( $size > 0){ |
|
400 | + if ($size > 0) { |
|
401 | 401 | return true; |
402 | - } else{ |
|
402 | + }else { |
|
403 | 403 | DB::table('uploads') |
404 | - ->where('id', $file['id']) |
|
405 | - ->update(['is_processed' =>2 , 'updated_at' => now()]); |
|
406 | - $this->stdOut('No valid data found :Please re-upload the file',0); |
|
407 | - $this->processEmptyEmail($file,$user, 'No valid data found :Please re-upload the file'); |
|
404 | + ->where('id', $file['id']) |
|
405 | + ->update(['is_processed' =>2, 'updated_at' => now()]); |
|
406 | + $this->stdOut('No valid data found :Please re-upload the file', 0); |
|
407 | + $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | - protected function setReader($file){ |
|
412 | - try{ |
|
413 | - $excelFile = '/sis-bulk-data-files/processed/' . $file['filename']; |
|
411 | + protected function setReader($file) { |
|
412 | + try { |
|
413 | + $excelFile = '/sis-bulk-data-files/processed/'.$file['filename']; |
|
414 | 414 | $exists = Storage::disk('local')->exists($excelFile); |
415 | - if(!$exists){ |
|
415 | + if (!$exists) { |
|
416 | 416 | |
417 | - $excelFile = "/sis-bulk-data-files/" . $file['filename']; |
|
417 | + $excelFile = "/sis-bulk-data-files/".$file['filename']; |
|
418 | 418 | } |
419 | - $excelFile = storage_path()."/app" . $excelFile; |
|
419 | + $excelFile = storage_path()."/app".$excelFile; |
|
420 | 420 | $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->getType($file['filename'])); |
421 | - $objPHPExcel = $reader->load($excelFile); |
|
421 | + $objPHPExcel = $reader->load($excelFile); |
|
422 | 422 | return $objPHPExcel; |
423 | - } catch (Exception $e){ |
|
424 | - $this->output->writeln( $e->getMessage()); |
|
423 | + }catch (Exception $e) { |
|
424 | + $this->output->writeln($e->getMessage()); |
|
425 | 425 | $user = User::find($file['security_user_id']); |
426 | 426 | DB::table('uploads') |
427 | - ->where('id', $file['id']) |
|
428 | - ->update(['is_processed' =>2 , 'updated_at' => now()]); |
|
429 | - $this->stdOut('No valid data found :Please re-upload the file',0); |
|
430 | - $this->processEmptyEmail($file,$user, 'No valid data found :Please re-upload the file'); |
|
427 | + ->where('id', $file['id']) |
|
428 | + ->update(['is_processed' =>2, 'updated_at' => now()]); |
|
429 | + $this->stdOut('No valid data found :Please re-upload the file', 0); |
|
430 | + $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
434 | - protected function getSheetName($file,$sheet){ |
|
435 | - try{; |
|
434 | + protected function getSheetName($file, $sheet) { |
|
435 | + try {; |
|
436 | 436 | $objPHPExcel = $this->setReader($file); |
437 | - return $objPHPExcel->getSheetByName($sheet) !== null; |
|
438 | - } catch (Exception $e){ |
|
439 | - $this->output->writeln( $e->getMessage()); |
|
437 | + return $objPHPExcel->getSheetByName($sheet) !== null; |
|
438 | + }catch (Exception $e) { |
|
439 | + $this->output->writeln($e->getMessage()); |
|
440 | 440 | $user = User::find($file['security_user_id']); |
441 | 441 | DB::table('uploads') |
442 | - ->where('id', $file['id']) |
|
443 | - ->update(['is_processed' =>2 , 'updated_at' => now()]); |
|
444 | - $this->stdOut('No valid data found :Please re-upload the file',0); |
|
445 | - $this->processEmptyEmail($file,$user, 'No valid data found :Please re-upload the file'); |
|
442 | + ->where('id', $file['id']) |
|
443 | + ->update(['is_processed' =>2, 'updated_at' => now()]); |
|
444 | + $this->stdOut('No valid data found :Please re-upload the file', 0); |
|
445 | + $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
449 | - protected function getHigestRow($file,$sheet,$column){ |
|
450 | - try{ |
|
449 | + protected function getHigestRow($file, $sheet, $column) { |
|
450 | + try { |
|
451 | 451 | $reader = $this->setReader($file); |
452 | 452 | $reader->setActiveSheetIndex($sheet); |
453 | 453 | $higestRow = 0; |
454 | - $highestRow = $reader->getActiveSheet()->getHighestRow($column); |
|
454 | + $highestRow = $reader->getActiveSheet()->getHighestRow($column); |
|
455 | 455 | for ($row = 3; $row <= $highestRow; $row++) { |
456 | 456 | $rowData = $reader->getActiveSheet()->getCell($column.$row)->getValue(); |
457 | 457 | if (empty($rowData) || $rowData == null) { |
458 | 458 | continue; |
459 | - } else { |
|
459 | + }else { |
|
460 | 460 | $higestRow += 1; |
461 | 461 | } |
462 | 462 | } |
463 | 463 | return $higestRow; |
464 | - } catch(\Exception $e){ |
|
465 | - $this->output->writeln( $e->getMessage()); |
|
464 | + }catch (\Exception $e) { |
|
465 | + $this->output->writeln($e->getMessage()); |
|
466 | 466 | $user = User::find($file['security_user_id']); |
467 | 467 | DB::beginTransaction(); |
468 | 468 | DB::table('uploads') |
469 | 469 | ->where('id', $file['id']) |
470 | - ->update(['is_processed' => 2,'updated_at' => now()]); |
|
470 | + ->update(['is_processed' => 2, 'updated_at' => now()]); |
|
471 | 471 | DB::commit(); |
472 | - $this->processEmptyEmail($file,$user, 'No valid data found'); |
|
472 | + $this->processEmptyEmail($file, $user, 'No valid data found'); |
|
473 | 473 | exit(); |
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | - protected function stdOut($title,$rows){ |
|
478 | - $this->output->writeln( $title. ' Process completed at . '.' '. now()); |
|
477 | + protected function stdOut($title, $rows) { |
|
478 | + $this->output->writeln($title.' Process completed at . '.' '.now()); |
|
479 | 479 | $now = Carbon::now()->tz('Asia/Colombo'); |
480 | - $this->output->writeln('Total Processed lines: ' . $rows); |
|
481 | - $this->output->writeln( 'Time taken to process : '. $now->diffInSeconds($this->startTime) .' Seconds'); |
|
480 | + $this->output->writeln('Total Processed lines: '.$rows); |
|
481 | + $this->output->writeln('Time taken to process : '.$now->diffInSeconds($this->startTime).' Seconds'); |
|
482 | 482 | $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------'); |
483 | 483 | } |
484 | 484 | |
485 | 485 | |
486 | 486 | |
487 | - protected function removeRows($row,$count,$params){ |
|
487 | + protected function removeRows($row, $count, $params) { |
|
488 | 488 | $reader = $params['reader']; |
489 | 489 | $sheet = $reader->getActiveSheet(); |
490 | - if(!in_array($row,$params['rows'])){ |
|
490 | + if (!in_array($row, $params['rows'])) { |
|
491 | 491 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
492 | - $this->output->writeln( ' removing row . '.' '. $row); |
|
492 | + $this->output->writeln(' removing row . '.' '.$row); |
|
493 | 493 | $reader->getActiveSheet()->getCellCollection()->removeRow($row); |
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | |
498 | - protected function writeErrors($e,$file,$sheet){ |
|
498 | + protected function writeErrors($e, $file, $sheet) { |
|
499 | 499 | try { |
500 | 500 | ini_set('memory_limit', '2048M'); |
501 | 501 | $baseMemory = memory_get_usage(); |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | unset($files); |
71 | 71 | exit(); |
72 | 72 | |
73 | - }else { |
|
73 | + } else { |
|
74 | 74 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
75 | 75 | $this->output->writeln('No files found,Waiting for files'); |
76 | 76 | exit(); |
77 | 77 | |
78 | 78 | } |
79 | 79 | |
80 | - }catch (Exception $e) { |
|
80 | + } catch (Exception $e) { |
|
81 | 81 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
82 | 82 | $this->output->writeln($e); |
83 | 83 | sleep(300); |
84 | 84 | $this->handle(); |
85 | 85 | |
86 | 86 | } |
87 | - }else { |
|
87 | + } else { |
|
88 | 88 | exit(); |
89 | 89 | } |
90 | 90 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | DB::table('uploads') |
162 | 162 | ->where('id', $file['id']) |
163 | 163 | ->update(['is_processed' => 1, 'is_email_sent' => 1, 'updated_at' => now()]); |
164 | - }catch (\Exception $ex) { |
|
164 | + } catch (\Exception $ex) { |
|
165 | 165 | $this->output->writeln($ex->getMessage()); |
166 | 166 | DB::table('uploads') |
167 | 167 | ->where('id', $file['id']) |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | DB::table('uploads') |
177 | 177 | ->where('id', $file['id']) |
178 | 178 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
179 | - }catch (\Exception $ex) { |
|
179 | + } catch (\Exception $ex) { |
|
180 | 180 | $this->output->writeln($ex->getMessage()); |
181 | 181 | DB::table('uploads') |
182 | 182 | ->where('id', $file['id']) |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | DB::table('uploads') |
192 | 192 | ->where('id', $file['id']) |
193 | 193 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
194 | - }catch (\Exception $ex) { |
|
194 | + } catch (\Exception $ex) { |
|
195 | 195 | $this->output->writeln($ex->getMessage()); |
196 | 196 | DB::table('uploads') |
197 | 197 | ->where('id', $file['id']) |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
206 | 206 | $this->output->writeln('Processing from:'.$node); |
207 | 207 | return true; |
208 | - }else { |
|
208 | + } else { |
|
209 | 209 | exit; |
210 | 210 | return false; |
211 | 211 | } |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | sleep(10); |
224 | 224 | $this->import($file, 2, 'B'); |
225 | 225 | |
226 | - }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
226 | + } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
227 | 227 | $this->output->writeln($e->getMessage()); |
228 | 228 | try { |
229 | 229 | Mail::to($user->email)->send(new IncorrectTemplate($file)); |
230 | 230 | DB::table('uploads') |
231 | 231 | ->where('id', $file['id']) |
232 | 232 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
233 | - }catch (\Exception $ex) { |
|
233 | + } catch (\Exception $ex) { |
|
234 | 234 | $this->output->writeln($e->getMessage()); |
235 | 235 | $this->handle(); |
236 | 236 | DB::table('uploads') |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]); |
239 | 239 | } |
240 | 240 | } |
241 | - }else { |
|
241 | + } else { |
|
242 | 242 | exit(); |
243 | 243 | } |
244 | 244 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | } |
360 | 360 | break; |
361 | 361 | } |
362 | - }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
362 | + } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
363 | 363 | $this->output->writeln( $e->getMessage()); |
364 | 364 | if($sheet == 1){ |
365 | 365 | self::writeErrors($e,$file,'Insert Students'); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ->where('id', $file['id']) |
368 | 368 | ->update(['insert' => 2,'updated_at' => now()]); |
369 | 369 | $this->processFailedEmail($file,$user,'Fresh Student Data Upload:Failed'); |
370 | - }else if($sheet == 2){ |
|
370 | + } else if($sheet == 2){ |
|
371 | 371 | self::writeErrors($e,$file,'Update Students'); |
372 | 372 | DB::table('uploads') |
373 | 373 | ->where('id', $file['id']) |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | unset($failures); |
535 | 535 | } |
536 | 536 | |
537 | - }catch (Eception $e) { |
|
537 | + } catch (Eception $e) { |
|
538 | 538 | $this->output->writeln($e->getMessage()); |
539 | 539 | $user = User::find($file['security_user_id']); |
540 | 540 | DB::beginTransaction(); |
@@ -204,19 +204,19 @@ |
||
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 | } |
@@ -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; |
@@ -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']); |
@@ -50,14 +50,14 @@ discard block |
||
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); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | DB::table('uploads') |
97 | 97 | ->where('id', $file['id']) |
98 | 98 | ->update(['is_processed' => 3, 'is_email_sent' => 1, 'updated_at' => now()]); |
99 | - }else { |
|
99 | + } else { |
|
100 | 100 | exit(); |
101 | 101 | } |
102 | 102 | } |