@@ -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']); |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | ]); |
| 141 | 141 | $institutionClassStudent = [$institutionClassStudent]; |
| 142 | 142 | array_walk($institutionClassStudent, array($this->class, 'updateClassCount')); |
| 143 | - $this->output->writeln("student record :".$student['student_id'] ); |
|
| 143 | + $this->output->writeln("student record :".$student['student_id']); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | - }catch(\Exception $e){ |
|
| 146 | + }catch (\Exception $e) { |
|
| 147 | 147 | dd($e); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -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 | }); |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | 'institution_students.admission_id' |
| 130 | 130 | ) |
| 131 | 131 | ->where('institution_students.institution_id', $institutionGrade['institution_id']) |
| 132 | - ->where('institution_students.student_status_id',1) |
|
| 132 | + ->where('institution_students.student_status_id', 1) |
|
| 133 | 133 | ->where('institution_students.education_grade_id', $institutionGrade['education_grade_id']) |
| 134 | - ->where('institution_students.deleted_at',null) |
|
| 134 | + ->where('institution_students.deleted_at', null) |
|
| 135 | 135 | ->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray(); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public static function createExaminationData($student, $admissionInfo) |
| 146 | 146 | { |
| 147 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 147 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 148 | 148 | try { |
| 149 | 149 | self::create([ |
| 150 | 150 | 'id' => (string) Uuid::generate(4), |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | 'created' => now(), |
| 170 | 170 | 'created_user_id' => 1 |
| 171 | 171 | ]); |
| 172 | - } catch (\Throwable $th) { |
|
| 172 | + }catch (\Throwable $th) { |
|
| 173 | 173 | Log::error($th); |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public static function updateExaminationData($student, $admissionInfo) |
| 185 | 185 | { |
| 186 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 186 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
| 187 | 187 | try { |
| 188 | 188 | self::where([ |
| 189 | 189 | 'student_id' => $student['student_id'], |
@@ -204,50 +204,50 @@ discard block |
||
| 204 | 204 | 'modified_user_id' => 1 |
| 205 | 205 | ] |
| 206 | 206 | ); |
| 207 | - } catch (\Throwable $th) { |
|
| 207 | + }catch (\Throwable $th) { |
|
| 208 | 208 | Log::error($th); |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - public static function updateStudentArea(array $student){ |
|
| 213 | - $father = Student_guardian::where('student_id',$student['student_id']) |
|
| 214 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
| 215 | - ->where('guardian_relation_id',1) |
|
| 212 | + public static function updateStudentArea(array $student) { |
|
| 213 | + $father = Student_guardian::where('student_id', $student['student_id']) |
|
| 214 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
| 215 | + ->where('guardian_relation_id', 1) |
|
| 216 | 216 | ->get()->first(); |
| 217 | 217 | |
| 218 | - $mother = Student_guardian::where('student_id',$student['student_id']) |
|
| 219 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
| 220 | - ->where('guardian_relation_id',2) |
|
| 218 | + $mother = Student_guardian::where('student_id', $student['student_id']) |
|
| 219 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
| 220 | + ->where('guardian_relation_id', 2) |
|
| 221 | 221 | ->get()->first(); |
| 222 | 222 | |
| 223 | - $guardian = Student_guardian::where('student_id',$student['student_id']) |
|
| 224 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
| 225 | - ->where('guardian_relation_id',3) |
|
| 223 | + $guardian = Student_guardian::where('student_id', $student['student_id']) |
|
| 224 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
| 225 | + ->where('guardian_relation_id', 3) |
|
| 226 | 226 | ->get()->first(); |
| 227 | 227 | |
| 228 | - if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
|
| 229 | - Security_user::where('id',$student['student_id']) |
|
| 228 | + if (!is_null($father) && is_null($mother) && is_null($guardian)) { |
|
| 229 | + Security_user::where('id', $student['student_id']) |
|
| 230 | 230 | ->update(['address_area_id' => $father->address_area_id]); |
| 231 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
| 232 | - Security_user::where('id',$student['student_id']) |
|
| 231 | + }elseif (!is_null($mother) && (is_null($father) && is_null($guardian))) { |
|
| 232 | + Security_user::where('id', $student['student_id']) |
|
| 233 | 233 | ->update(['address_area_id' => $mother->address_area_id]); |
| 234 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
| 235 | - Security_user::where('id',$student['student_id']) |
|
| 234 | + }elseif (!is_null($guardian) && is_null($father) && is_null($mother)) { |
|
| 235 | + Security_user::where('id', $student['student_id']) |
|
| 236 | 236 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 237 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
| 238 | - Security_user::where('id',$student['student_id']) |
|
| 237 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) { |
|
| 238 | + Security_user::where('id', $student['student_id']) |
|
| 239 | 239 | ->update(['address_area_id' => $mother->address_area_id]); |
| 240 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
| 241 | - Security_user::where('id',$student['student_id']) |
|
| 240 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) { |
|
| 241 | + Security_user::where('id', $student['student_id']) |
|
| 242 | 242 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 243 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
| 244 | - Security_user::where('id',$student['student_id']) |
|
| 243 | + }elseif (!is_null($father) && $father->address == $student['address']) { |
|
| 244 | + Security_user::where('id', $student['student_id']) |
|
| 245 | 245 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 246 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
| 247 | - Security_user::where('id',$student['student_id']) |
|
| 246 | + }elseif (!is_null($mother) && $mother->address == $student['address']) { |
|
| 247 | + Security_user::where('id', $student['student_id']) |
|
| 248 | 248 | ->update(['address_area_id' => $mother->address_area_id]); |
| 249 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
| 250 | - Security_user::where('id',$student['student_id']) |
|
| 249 | + }elseif (!is_null($guardian) && $guardian->address == $student['address']) { |
|
| 250 | + Security_user::where('id', $student['student_id']) |
|
| 251 | 251 | ->update(['address_area_id' => $guardian->address_area_id]); |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -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, $params); |
|
| 97 | + $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode, $params); |
|
| 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 | } |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | try { |
| 168 | 168 | if ($params['mode']) { |
| 169 | 169 | Institution_class::where('id', $class['id']) |
| 170 | - ->where('academic_period_id',$params['previous_academic_period_id']) |
|
| 170 | + ->where('academic_period_id', $params['previous_academic_period_id']) |
|
| 171 | 171 | ->update([ |
| 172 | 172 | 'institution_shift_id' => $params['shift_id'], |
| 173 | 173 | 'academic_period_id' => $params['academic_period_id'] |
| 174 | 174 | ]); |
| 175 | 175 | |
| 176 | 176 | Institution_class_student::where('institution_class_id', $class['id']) |
| 177 | - ->where('academic_period_id',$params['previous_academic_period_id']) |
|
| 177 | + ->where('academic_period_id', $params['previous_academic_period_id']) |
|
| 178 | 178 | ->update([ |
| 179 | 179 | 'academic_period_id' => $params['academic_period_id'], |
| 180 | 180 | 'modified' => now() |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | $educationGrade = Institution_class_grade::select('education_grade_id')->where('institution_class_id', $class['id'])->get()->toArray(); |
| 184 | 184 | |
| 185 | 185 | Institution_student::whereIn('education_grade_id', $educationGrade) |
| 186 | - ->where('academic_period_id',$params['previous_academic_period_id']) |
|
| 186 | + ->where('academic_period_id', $params['previous_academic_period_id']) |
|
| 187 | 187 | ->update([ |
| 188 | 188 | 'academic_period_id' => $params['academic_period_id'] |
| 189 | 189 | ]); |
| 190 | 190 | } |
| 191 | - } catch (\Exception $e) { |
|
| 191 | + }catch (\Exception $e) { |
|
| 192 | 192 | DB::rollBack(); |
| 193 | 193 | Log::error($e->getMessage(), [$e]); |
| 194 | 194 | } |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $class['created'] = now(); |
| 219 | 219 | $class['institution_shift_id'] = $param['shift_id']; |
| 220 | 220 | // $class['created_user_id'] = |
| 221 | - $this->output->writeln('Create class:' . $class['name']); |
|
| 222 | - $class = Institution_class::create($class); |
|
| 221 | + $this->output->writeln('Create class:'.$class['name']); |
|
| 222 | + $class = Institution_class::create($class); |
|
| 223 | 223 | $institutionClassGrdaeObj['institution_class_id'] = $class->id; |
| 224 | 224 | $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae; |
| 225 | 225 | $institutionClassGrdaeObj['created_user_id'] = $class['created_user_id']; |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | ->toArray(); |
| 232 | 232 | $params['class'] = $class; |
| 233 | 233 | $this->insertInstitutionClassSubjects($institutionSubjects, $class); |
| 234 | - } catch (\Exception $e) { |
|
| 234 | + }catch (\Exception $e) { |
|
| 235 | 235 | DB::rollBack(); |
| 236 | 236 | Log::error($e->getMessage(), [$e]); |
| 237 | 237 | } |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | if (!empty($subjects)) { |
| 243 | 243 | try { |
| 244 | 244 | array_walk($subjects, array($this, 'insertClassSubjects'), $class); |
| 245 | - $this->output->writeln('updating subjects ' . $class->name); |
|
| 246 | - } catch (\Exception $e) { |
|
| 245 | + $this->output->writeln('updating subjects '.$class->name); |
|
| 246 | + }catch (\Exception $e) { |
|
| 247 | 247 | DB::rollBack(); |
| 248 | 248 | Log::error($e->getMessage(), [$e]); |
| 249 | 249 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | if (!$this->institution_class_subjects->isDuplicated($subjectobj)) { |
| 265 | 265 | $this->institution_class_subjects->create($subjectobj); |
| 266 | 266 | } |
| 267 | - } catch (\Exception $e) { |
|
| 267 | + }catch (\Exception $e) { |
|
| 268 | 268 | DB::rollBack(); |
| 269 | 269 | Log::error($e->getMessage(), [$e]); |
| 270 | 270 | } |
@@ -312,19 +312,19 @@ discard block |
||
| 312 | 312 | unset($shift['id']); |
| 313 | 313 | unset($shift['created']); |
| 314 | 314 | unset($shift['modified']); |
| 315 | - $shift = $this->shifts->create((array)$shift); |
|
| 315 | + $shift = $this->shifts->create((array) $shift); |
|
| 316 | 316 | $data = [ |
| 317 | 317 | 'shift_id' => $shift->id, |
| 318 | 318 | 'created' => true |
| 319 | 319 | ]; |
| 320 | - } else { |
|
| 320 | + }else { |
|
| 321 | 321 | $data = [ |
| 322 | 322 | 'shift_id' => $exist->id, |
| 323 | 323 | 'created' => false |
| 324 | 324 | ]; |
| 325 | 325 | }; |
| 326 | 326 | return $data; |
| 327 | - } catch (\Exception $e) { |
|
| 327 | + }catch (\Exception $e) { |
|
| 328 | 328 | DB::rollBack(); |
| 329 | 329 | } |
| 330 | 330 | } |
@@ -68,12 +68,12 @@ |
||
| 68 | 68 | ->where('academic_periods.code', $year); |
| 69 | 69 | |
| 70 | 70 | if ($mode) { |
| 71 | - $query->whereIn('institution_shifts.cloned',['2020']); |
|
| 72 | - } else { |
|
| 73 | - $query->whereNotIn('institution_shifts.cloned',['2020','2019/2020']); |
|
| 71 | + $query->whereIn('institution_shifts.cloned', ['2020']); |
|
| 72 | + }else { |
|
| 73 | + $query->whereNotIn('institution_shifts.cloned', ['2020', '2019/2020']); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $data = $query->groupBy('institution_shifts.id') |
|
| 76 | + $data = $query->groupBy('institution_shifts.id') |
|
| 77 | 77 | ->limit($limit) |
| 78 | 78 | ->get() |
| 79 | 79 | ->toArray(); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - public function getShiftClasses($shift, $al , $param = []) |
|
| 63 | + public function getShiftClasses($shift, $al, $param = []) |
|
| 64 | 64 | { |
| 65 | 65 | $query = self::query() |
| 66 | 66 | ->select( |
@@ -75,20 +75,20 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | ) |
| 77 | 77 | ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id') |
| 78 | - ->join('education_grades','institution_class_grades.education_grade_id','education_grades.id') |
|
| 78 | + ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
|
| 79 | 79 | ->join('education_programmes', 'education_grades.education_programme_id', 'education_programmes.id') |
| 80 | - ->join('education_cycles', 'education_programmes.education_cycle_id','education_cycles.id') |
|
| 80 | + ->join('education_cycles', 'education_programmes.education_cycle_id', 'education_cycles.id') |
|
| 81 | 81 | ->groupBy('institution_classes.id'); |
| 82 | 82 | |
| 83 | 83 | if ($al == true) { |
| 84 | 84 | $query->where('education_programmes.education_cycle_id', 4) |
| 85 | 85 | ->where('institution_shift_id', $shift['id']) |
| 86 | - ->where('institution_classes.academic_period_id',$param['previous_academic_period_id']); |
|
| 86 | + ->where('institution_classes.academic_period_id', $param['previous_academic_period_id']); |
|
| 87 | 87 | $data = $query |
| 88 | 88 | ->groupBy('institution_classes.id') |
| 89 | 89 | ->get()->toArray(); |
| 90 | 90 | return $data; |
| 91 | - } else { |
|
| 91 | + }else { |
|
| 92 | 92 | $query |
| 93 | 93 | // ->where('education_programmes.education_cycle_id','<>',4) |
| 94 | 94 | ->where('institution_shift_id', $shift['id']); |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function getGradeClasses($education_grade_id,$institution_id){ |
|
| 102 | + public static function getGradeClasses($education_grade_id, $institution_id) { |
|
| 103 | 103 | return self::query() |
| 104 | - ->select('institution_classes.id','institution_classes.institution_id','institution_classes.institution_shift_id', |
|
| 105 | - 'institution_classes.name','institution_classes.no_of_students','institution_classes.class_number','institution_class_grades.education_grade_id') |
|
| 106 | - ->where('institution_class_grades.education_grade_id',$education_grade_id) |
|
| 107 | - ->where('institution_classes.institution_id',$institution_id) |
|
| 108 | - ->join('institution_class_grades','institution_classes.id','institution_class_grades.institution_class_id') |
|
| 104 | + ->select('institution_classes.id', 'institution_classes.institution_id', 'institution_classes.institution_shift_id', |
|
| 105 | + 'institution_classes.name', 'institution_classes.no_of_students', 'institution_classes.class_number', 'institution_class_grades.education_grade_id') |
|
| 106 | + ->where('institution_class_grades.education_grade_id', $education_grade_id) |
|
| 107 | + ->where('institution_classes.institution_id', $institution_id) |
|
| 108 | + ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id') |
|
| 109 | 109 | ->get()->toArray(); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | if (!empty($isAvailableforPromotion)) { |
| 65 | 65 | $this->process($institutionGrade, $nextGrade, $params); |
| 66 | 66 | DB::commit(); |
| 67 | - } else { |
|
| 67 | + }else { |
|
| 68 | 68 | DB::rollBack(); |
| 69 | 69 | } |
| 70 | 70 | //leave school levers |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // $this->process($institutionGrade, $nextGrade, $params); |
| 73 | 73 | // } |
| 74 | 74 | } |
| 75 | - } catch (\Exception $e) { |
|
| 75 | + }catch (\Exception $e) { |
|
| 76 | 76 | DB::rollBack(); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 107 | 107 | $output->writeln('##########################################################################################################################'); |
| 108 | - $output->writeln('Promoting from ' . $institutionGrade['name'] . ' IN ' . $institution->name . ' No of Students: ' . count($studentListToPromote)); |
|
| 108 | + $output->writeln('Promoting from '.$institutionGrade['name'].' IN '.$institution->name.' No of Students: '.count($studentListToPromote)); |
|
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | if (!empty($parallelClasses)) { |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | array_walk($parallelClasses, array($this, 'updateStudentCount')); |
| 121 | 121 | DB::commit(); |
| 122 | 122 | } |
| 123 | - } catch (\Exception $e) { |
|
| 123 | + }catch (\Exception $e) { |
|
| 124 | 124 | DB::rollBack(); |
| 125 | 125 | Log::error($e->getMessage()); |
| 126 | 126 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $previousAcademicPeriod = $params['previousAcademicPeriod']; |
| 156 | 156 | $nextGradeObj = null; |
| 157 | 157 | $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $institutionGrade['education_grade_id'], $previousAcademicPeriod->id); |
| 158 | - if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
| 158 | + if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
| 159 | 159 | $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $nextGrade->id, $academicPeriod->id); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | // promote parallel classes |
| 165 | 165 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, $nextGradeObj->toArray(), 1); |
| 166 | 166 | return 1; |
| 167 | - } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
| 167 | + } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
| 168 | 168 | // promote pool promotion |
| 169 | 169 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, [], 1); |
| 170 | 170 | return 2; |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | // Promote matching class name with previous class |
| 173 | 173 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, $nextGradeObj->toArray(), 1); |
| 174 | 174 | return 1; |
| 175 | - } else { |
|
| 175 | + }else { |
|
| 176 | 176 | // default pool promotion |
| 177 | 177 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, [], 1); |
| 178 | 178 | return 2; |
| 179 | 179 | } |
| 180 | - } else { |
|
| 180 | + }else { |
|
| 181 | 181 | // default pool promotion |
| 182 | 182 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, [], 3); |
| 183 | 183 | return 2; |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | ]; |
| 214 | 214 | |
| 215 | 215 | try { |
| 216 | - Institution_student::where('id', (string)$student['id'])->update($studentData); |
|
| 216 | + Institution_student::where('id', (string) $student['id'])->update($studentData); |
|
| 217 | 217 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 218 | - $output->writeln('----------------- ' . $student['admission_id'] . ' to ' . $studentData['education_grade_id']); |
|
| 219 | - } catch (\Exception $e) { |
|
| 218 | + $output->writeln('----------------- '.$student['admission_id'].' to '.$studentData['education_grade_id']); |
|
| 219 | + }catch (\Exception $e) { |
|
| 220 | 220 | Log::error($e->getMessage()); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -236,13 +236,13 @@ discard block |
||
| 236 | 236 | $studentClass = $this->institution_class_students->getStudentNewClass($student); |
| 237 | 237 | if (!is_null($studentClass)) { |
| 238 | 238 | $class = array_search(str_replace($educationGrade['name'], $nextGrade->name, $studentClass->name), array_column($classes, 'name')); |
| 239 | - if(!($class)){ |
|
| 240 | - $nextGradeName = explode(" ",$nextGrade->name)[0]; |
|
| 241 | - $educationGrade['name'] = explode(" ",$educationGrade['name'])[0]; |
|
| 239 | + if (!($class)) { |
|
| 240 | + $nextGradeName = explode(" ", $nextGrade->name)[0]; |
|
| 241 | + $educationGrade['name'] = explode(" ", $educationGrade['name'])[0]; |
|
| 242 | 242 | $class = array_search(str_replace($educationGrade['name'], $nextGradeName, $studentClass->name), array_column($classes, 'name')); |
| 243 | 243 | } |
| 244 | 244 | return $class; |
| 245 | - } else { |
|
| 245 | + }else { |
|
| 246 | 246 | return false; |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $class = null; |
| 265 | 265 | if (count($classes) == 1) { |
| 266 | 266 | $class = $classes[0]; |
| 267 | - } else { |
|
| 267 | + }else { |
|
| 268 | 268 | $class = $this->getStudentClass($student, $educationGrade, $nextGrade, $classes); |
| 269 | 269 | if (is_numeric($class)) { |
| 270 | 270 | $class = $classes[$class]; |
@@ -296,13 +296,13 @@ discard block |
||
| 296 | 296 | // array_walk($allInsSubjects,array($this,'updateSubjectCount')); |
| 297 | 297 | // } |
| 298 | 298 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 299 | - $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']); |
|
| 300 | - } else { |
|
| 301 | - $this->institution_class_students->where('id', (string)$student['id'])->update($studentObj); |
|
| 299 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
| 300 | + }else { |
|
| 301 | + $this->institution_class_students->where('id', (string) $student['id'])->update($studentObj); |
|
| 302 | 302 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 303 | - $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']); |
|
| 303 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
| 304 | 304 | } |
| 305 | - } catch (\Exception $e) { |
|
| 305 | + }catch (\Exception $e) { |
|
| 306 | 306 | |
| 307 | 307 | Log::error($e->getMessage()); |
| 308 | 308 | } |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | public function getParallelClasses($id, $institutionId, $educationGradeId, $academicPeriodId) |
| 71 | 71 | { |
| 72 | 72 | $data = self::find($id)->select('institution_grades.id as insGrade', 'institution_classes.id', 'institution_classes.name', 'institution_grades.education_grade_id') |
| 73 | - ->join('institution_classes', function ($join) use ($educationGradeId, $academicPeriodId) { |
|
| 73 | + ->join('institution_classes', function($join) use ($educationGradeId, $academicPeriodId) { |
|
| 74 | 74 | $join->on('institution_classes.institution_id', '=', 'institution_grades.institution_id') |
| 75 | 75 | ->where('institution_classes.academic_period_id', $academicPeriodId) |
| 76 | - ->join('institution_class_grades', function ($join) use ($educationGradeId) { |
|
| 76 | + ->join('institution_class_grades', function($join) use ($educationGradeId) { |
|
| 77 | 77 | $join->on('institution_class_grades.institution_class_id', '=', 'institution_classes.id') |
| 78 | 78 | ->where('institution_class_grades.education_grade_id', $educationGradeId); |
| 79 | 79 | }) |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | ->select('education_grades.name', 'institutions.code', 'institutions.name as institution_name', 'institution_grades.id', 'institution_grades.institution_id', 'institution_grades.education_grade_id') |
| 124 | 124 | // ->where('promoted', '=', $year) |
| 125 | 125 | ->join('education_grades', 'institution_grades.education_grade_id', '=', 'education_grades.id') |
| 126 | - ->join('institutions', function ($join) use ($year, $institution) { |
|
| 126 | + ->join('institutions', function($join) use ($year, $institution) { |
|
| 127 | 127 | $join->on('institutions.id', '=', 'institution_grades.institution_id') |
| 128 | 128 | ->where('institutions.code', '=', $institution); |
| 129 | 129 | }) |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | break; |
| 135 | 135 | case '6-11': |
| 136 | 136 | $query->whereIn('education_programmes.education_cycle_id', [2, 3]); |
| 137 | - $query->whereNotIn('education_grades.id',[29,34]); |
|
| 137 | + $query->whereNotIn('education_grades.id', [29, 34]); |
|
| 138 | 138 | break; |
| 139 | 139 | case 'AL': |
| 140 | 140 | $query->where('education_programmes.education_cycle_id', 4); |
@@ -152,21 +152,21 @@ discard block |
||
| 152 | 152 | * @param $year |
| 153 | 153 | * @return mixed |
| 154 | 154 | */ |
| 155 | - public function getInstitutionGradeList($year, $limit,$mode) |
|
| 155 | + public function getInstitutionGradeList($year, $limit, $mode) |
|
| 156 | 156 | { |
| 157 | 157 | $query = $this->select('education_grades.name', 'institutions.code', 'institutions.name as institution_name', 'institution_grades.id', 'institution_grades.institution_id', 'institution_grades.education_grade_id') |
| 158 | 158 | // ->where('promoted', '=', $year) |
| 159 | 159 | ->join('education_grades', 'institution_grades.education_grade_id', '=', 'education_grades.id') |
| 160 | - ->join('institutions', function ($join) use ($year) { |
|
| 160 | + ->join('institutions', function($join) use ($year) { |
|
| 161 | 161 | $join->on('institutions.id', '=', 'institution_grades.institution_id'); |
| 162 | 162 | }) |
| 163 | 163 | ->join('education_programmes', 'education_grades.education_programme_id', 'education_programmes.id'); |
| 164 | 164 | switch ($mode) { |
| 165 | 165 | case '1-5': |
| 166 | - $query->whereIn('education_programmes.education_cycle_id', [1,2]); |
|
| 166 | + $query->whereIn('education_programmes.education_cycle_id', [1, 2]); |
|
| 167 | 167 | break; |
| 168 | 168 | case '6-11': |
| 169 | - $query->whereIn('education_programmes.education_cycle_id', [2,3,4]); |
|
| 169 | + $query->whereIn('education_programmes.education_cycle_id', [2, 3, 4]); |
|
| 170 | 170 | break; |
| 171 | 171 | case 'AL': |
| 172 | 172 | $query->where('education_programmes.education_cycle_id', 4); |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | return $data; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function getGradeSubjects($institutionId){ |
|
| 184 | + public function getGradeSubjects($institutionId) { |
|
| 185 | 185 | return self::query() |
| 186 | - ->select('institution_grades.institution_id','education_grades_subjects.education_grade_id','education_grades_subjects.education_subject_id','education_subjects.name') |
|
| 187 | - ->where('institution_grades.institution_id',$institutionId) |
|
| 186 | + ->select('institution_grades.institution_id', 'education_grades_subjects.education_grade_id', 'education_grades_subjects.education_subject_id', 'education_subjects.name') |
|
| 187 | + ->where('institution_grades.institution_id', $institutionId) |
|
| 188 | 188 | ->join('education_grades', 'institution_grades.education_grade_id', 'education_grades.id') |
| 189 | - ->join('education_grades_subjects','education_grades.id','education_grades_subjects.education_grade_id') |
|
| 190 | - ->join('education_subjects','education_grades_subjects.education_subject_id','education_subjects.id') |
|
| 189 | + ->join('education_grades_subjects', 'education_grades.id', 'education_grades_subjects.education_grade_id') |
|
| 190 | + ->join('education_subjects', 'education_grades_subjects.education_subject_id', 'education_subjects.id') |
|
| 191 | 191 | ->groupBy('education_grades_subjects.id') |
| 192 | 192 | ->get() |
| 193 | 193 | ->toArray(); |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | if (empty($value)) { |
| 73 | 73 | return false; |
| 74 | 74 | } elseif ($gradeEntity !== null) { |
| 75 | - $admissionAge = (($gradeEntity->admission_age) * 12) - 1; |
|
| 75 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
| 76 | 76 | $to = $academicPeriod->start_date; |
| 77 | 77 | $diff_in_months = $to->diffInMonths($value); |
| 78 | 78 | $ageOfStudent = $diff_in_months; |
| 79 | 79 | $enrolmentMaximumAge = $admissionAge + 120; |
| 80 | 80 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
| 81 | - } else { |
|
| 81 | + }else { |
|
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | - } else { |
|
| 85 | - $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found'; |
|
| 84 | + }else { |
|
| 85 | + $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found'; |
|
| 86 | 86 | $this->_set_custom_stuff(); |
| 87 | 87 | return false; |
| 88 | 88 | } |
@@ -93,16 +93,16 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | if (is_numeric($value)) { |
| 95 | 95 | if ($value < 10) { |
| 96 | - $this->_custom_messages['bmi'] = $attribute . ' is must greater than 10'; |
|
| 96 | + $this->_custom_messages['bmi'] = $attribute.' is must greater than 10'; |
|
| 97 | 97 | $this->_set_custom_stuff(); |
| 98 | 98 | return false; |
| 99 | 99 | } elseif ($value > 250) { |
| 100 | - $this->_custom_messages['bmi'] = $attribute . ' is must smaller than 250'; |
|
| 100 | + $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250'; |
|
| 101 | 101 | $this->_set_custom_stuff(); |
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | - } else { |
|
| 105 | - $this->_custom_messages['bmi'] = $attribute . ' is must a valid numeric'; |
|
| 104 | + }else { |
|
| 105 | + $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric'; |
|
| 106 | 106 | $this->_set_custom_stuff(); |
| 107 | 107 | return false; |
| 108 | 108 | } |
@@ -111,18 +111,18 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | protected function validateBmi($attribute, $value, $parameters) |
| 113 | 113 | { |
| 114 | - $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
| 114 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
| 115 | 115 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
| 116 | 116 | ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
| 117 | 117 | ->first(); |
| 118 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
| 118 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
| 119 | 119 | if (in_array($institutionGrade->code, $bmiGrades)) { |
| 120 | 120 | if (!empty($value)) { |
| 121 | 121 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
| 122 | 122 | return $this->validateHW($attribute, $value); |
| 123 | 123 | } |
| 124 | - } else { |
|
| 125 | - $this->_custom_messages['bmi'] = $attribute . ' is required for ' . $educationGrade->name; |
|
| 124 | + }else { |
|
| 125 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
| 126 | 126 | $this->_set_custom_stuff(); |
| 127 | 127 | return false; |
| 128 | 128 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
| 131 | 131 | return $this->validateHW($attribute, $value); |
| 132 | 132 | } |
| 133 | - } else { |
|
| 133 | + }else { |
|
| 134 | 134 | return true; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -139,19 +139,19 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | foreach ($validator->getData() as $data) { |
| 141 | 141 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
| 142 | - $BirthDivision = Area_administrative::where('name', '=', '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); // |
|
| 142 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
| 143 | 143 | if ($BirthDivision->count() > 0) { |
| 144 | - $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
| 144 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
| 145 | 145 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
| 146 | - return $BirthArea > 0; |
|
| 146 | + return $BirthArea > 0; |
|
| 147 | 147 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
| 148 | 148 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
| 149 | 149 | $this->_set_custom_stuff(); |
| 150 | 150 | return false; |
| 151 | - } else { |
|
| 151 | + }else { |
|
| 152 | 152 | return true; |
| 153 | 153 | } |
| 154 | - } else { |
|
| 154 | + }else { |
|
| 155 | 155 | return true; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -159,22 +159,22 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) |
| 161 | 161 | { |
| 162 | - $student = Security_user::where('openemis_no', '=', $value); |
|
| 162 | + $student = Security_user::where('openemis_no', '=', $value); |
|
| 163 | 163 | if ($student->count() > 0) { |
| 164 | 164 | $student = $student->first()->toArray(); |
| 165 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
| 165 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
| 166 | 166 | if ($check == 1) { |
| 167 | 167 | return true; |
| 168 | - } else { |
|
| 168 | + }else { |
|
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | - } else { |
|
| 171 | + }else { |
|
| 172 | 172 | return false; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | protected function validateNic($attribute, $value, $perameters, $validator) |
| 176 | 176 | { |
| 177 | - switch($data['identity_type']){ |
|
| 177 | + switch ($data['identity_type']) { |
|
| 178 | 178 | case 'BC': |
| 179 | 179 | //inclde the bc validation |
| 180 | 180 | break; |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value); |
| 186 | 186 | if (!$valid) { |
| 187 | - $this->_custom_messages['nic'] = $attribute . ' is not valid, Please check the NIC number'; |
|
| 187 | + $this->_custom_messages['nic'] = $attribute.' is not valid, Please check the NIC number'; |
|
| 188 | 188 | $this->_set_custom_stuff(); |
| 189 | 189 | return false; |
| 190 | - } else { |
|
| 190 | + }else { |
|
| 191 | 191 | return true; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | protected function validateUserUnique($attribute, $value, $perameters, $validator) |
| 196 | 196 | { |
| 197 | 197 | foreach ($validator->getData() as $data) { |
| 198 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 198 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 199 | 199 | if ($identityType !== null && ($value !== null)) { |
| 200 | 200 | if ($identityType->national_code === 'BC') { |
| 201 | 201 | return $this->checkUnique($value, $data, $identityType); |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | protected function validateIsBc($attribute, $value, $perameters, $validator) |
| 212 | 212 | { |
| 213 | 213 | foreach ($validator->getData() as $data) { |
| 214 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 214 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 215 | 215 | if (($identityType !== null) && ($identityType !== "")) { |
| 216 | 216 | if (($identityType->national_code) === 'BC') { |
| 217 | 217 | return (strlen((string) $data['identity_number']) < 7); |
| 218 | - } else { |
|
| 218 | + }else { |
|
| 219 | 219 | return true; |
| 220 | 220 | } |
| 221 | - } else { |
|
| 221 | + }else { |
|
| 222 | 222 | return true; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | { |
| 229 | 229 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
| 230 | 230 | if ($isUnique->count() > 0) { |
| 231 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
| 231 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
| 232 | 232 | $this->_set_custom_stuff(); |
| 233 | 233 | return false; |
| 234 | - } else { |
|
| 234 | + }else { |
|
| 235 | 235 | return true; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | protected function IsBc($data, $value) |
| 240 | 240 | { |
| 241 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
| 241 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
| 242 | 242 | if ($identityType !== null) { |
| 243 | 243 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
| 244 | 244 | return false; |
| 245 | - } else { |
|
| 245 | + }else { |
|
| 246 | 246 | return true; |
| 247 | 247 | } |
| 248 | - } else { |
|
| 248 | + }else { |
|
| 249 | 249 | return true; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | foreach ($validator->getData() as $data) { |
| 260 | 260 | |
| 261 | 261 | |
| 262 | - if(($data['identity_type'] != null)&&($value != null)) |
|
| 262 | + if (($data['identity_type'] != null) && ($value != null)) |
|
| 263 | 263 | { |
| 264 | 264 | //dd(true); |
| 265 | 265 | |
| 266 | - if(!strcmp($data['identity_type'],"BC")) |
|
| 266 | + if (!strcmp($data['identity_type'], "BC")) |
|
| 267 | 267 | { |
| 268 | 268 | $out = 1; |
| 269 | 269 | } |
@@ -272,18 +272,18 @@ discard block |
||
| 272 | 272 | $out = 2; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if(($out == 1)&&(preg_match('/^[0-9]{4}+$/',$value))) |
|
| 275 | + if (($out == 1) && (preg_match('/^[0-9]{4}+$/', $value))) |
|
| 276 | 276 | { |
| 277 | 277 | //dd(true); |
| 278 | 278 | return true; |
| 279 | 279 | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - elseif (($out == 2) &&(preg_match('/^[0-9]{9}[VX]{1}+$/',$value))) |
|
| 282 | + elseif (($out == 2) && (preg_match('/^[0-9]{9}[VX]{1}+$/', $value))) |
|
| 283 | 283 | { |
| 284 | 284 | return true; |
| 285 | 285 | } |
| 286 | - elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/',$value))) |
|
| 286 | + elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/', $value))) |
|
| 287 | 287 | { |
| 288 | 288 | return true; |
| 289 | 289 | } |
@@ -295,22 +295,22 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | - else if(($data['identity_type'] != null)&&($value == null)){ |
|
| 298 | + else if (($data['identity_type'] != null) && ($value == null)) { |
|
| 299 | 299 | return true; |
| 300 | 300 | } |
| 301 | 301 | else { |
| 302 | - if(preg_match('/^[0-9]{4}+$/',$value)) |
|
| 302 | + if (preg_match('/^[0-9]{4}+$/', $value)) |
|
| 303 | 303 | { |
| 304 | 304 | //dd(true); |
| 305 | 305 | return true; |
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - elseif (preg_match('/^[0-9]{9}[VX]{1}+$/',$value)) |
|
| 309 | + elseif (preg_match('/^[0-9]{9}[VX]{1}+$/', $value)) |
|
| 310 | 310 | { |
| 311 | 311 | return true; |
| 312 | 312 | } |
| 313 | - elseif (preg_match('/^[0-9]{12}+$/',$value)) |
|
| 313 | + elseif (preg_match('/^[0-9]{12}+$/', $value)) |
|
| 314 | 314 | { |
| 315 | 315 | return true; |
| 316 | 316 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function boot() |
| 29 | 29 | { |
| 30 | 30 | // |
| 31 | - if(!(\App::environment('local'))) { |
|
| 31 | + if (!(\App::environment('local'))) { |
|
| 32 | 32 | URL::forceScheme('https'); |
| 33 | 33 | } |
| 34 | 34 | } |