Test Setup Failed
Pull Request — master (#638)
by Mohamed
12:09
created
app/Http/Controllers/CloneController.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -31,21 +31,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
94 94
 
95 95
 
96 96
         if ($mode) {
97
-            $institutionClasses = $this->institution_classes->getShiftClasses($shift,  $mode);
97
+            $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode);
98 98
             try {
99 99
                 array_walk($institutionClasses, array($this, 'updateInstitutionClasses'), $params);
100
-                $this->output->writeln('updating from ' . $shift['institution_id']);
101
-            } catch (\Exception $e) {
100
+                $this->output->writeln('updating from '.$shift['institution_id']);
101
+            }catch (\Exception $e) {
102 102
                 Log::error($e->getMessage(), [$e]);
103 103
             }
104
-        } else {
104
+        }else {
105 105
             $institutionSubjects = $this->institution_grades->getGradeSubjects($shift['institution_id']);
106 106
             try {
107 107
                 if ($data['created']) {
@@ -112,32 +112,32 @@  discard block
 block discarded – undo
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
                         $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode);
127 127
                         $shift['id'] = $shiftId;
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
 block discarded – undo
156 156
             $subject['created'] = now();
157 157
             $subject['created_user_id'] = 1;
158 158
             $this->institution_subjects->create($subject);
159
-        } catch (\Exception $e) {
159
+        }catch (\Exception $e) {
160 160
             DB::rollBack();
161 161
             Log::error($e->getMessage(), [$e]);
162 162
         }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                         'academic_period_id' => $params['academic_period_id']
186 186
                     ]);
187 187
             }
188
-        } catch (\Exception $e) {
188
+        }catch (\Exception $e) {
189 189
             DB::rollBack();
190 190
             Log::error($e->getMessage(), [$e]);
191 191
         }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
             $class['created'] = now();
216 216
             $class['institution_shift_id'] = $param['shift_id'];
217 217
             // $class['created_user_id'] = 
218
-            $this->output->writeln('Create class:' . $class['name']);
219
-            $class =  Institution_class::create($class);
218
+            $this->output->writeln('Create class:'.$class['name']);
219
+            $class = Institution_class::create($class);
220 220
             $institutionClassGrdaeObj['institution_class_id'] = $class->id;
221 221
             $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae;
222 222
             $institutionClassGrdaeObj['created_user_id'] = $class['created_user_id'];
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 ->toArray();
229 229
             $params['class'] = $class;
230 230
             $this->insertInstitutionClassSubjects($institutionSubjects, $class);
231
-        } catch (\Exception $e) {
231
+        }catch (\Exception $e) {
232 232
             DB::rollBack();
233 233
             Log::error($e->getMessage(), [$e]);
234 234
         }
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
         if (!empty($subjects)) {
240 240
             try {
241 241
                 array_walk($subjects, array($this, 'insertClassSubjects'), $class);
242
-                $this->output->writeln('updating subjects ' . $class->name);
243
-            } catch (\Exception $e) {
242
+                $this->output->writeln('updating subjects '.$class->name);
243
+            }catch (\Exception $e) {
244 244
                 DB::rollBack();
245 245
                 Log::error($e->getMessage(), [$e]);
246 246
             }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
             if (!$this->institution_class_subjects->isDuplicated($subjectobj)) {
262 262
                 $this->institution_class_subjects->create($subjectobj);
263 263
             }
264
-        } catch (\Exception $e) {
264
+        }catch (\Exception $e) {
265 265
             DB::rollBack();
266 266
             Log::error($e->getMessage(), [$e]);
267 267
         }
@@ -309,19 +309,19 @@  discard block
 block discarded – undo
309 309
                 unset($shift['id']);
310 310
                 unset($shift['created']);
311 311
                 unset($shift['modified']);
312
-                $shift = $this->shifts->create((array)$shift);
312
+                $shift = $this->shifts->create((array) $shift);
313 313
                 $data = [
314 314
                     'shift_id' => $shift->id,
315 315
                     'created' => true
316 316
                 ];
317
-            } else {
317
+            }else {
318 318
                 $data = [
319 319
                     'shift_id' => $exist->id,
320 320
                     'created' => false
321 321
                 ];
322 322
             };
323 323
             return $data;
324
-        } catch (\Exception $e) {
324
+        }catch (\Exception $e) {
325 325
             DB::rollBack();
326 326
         }
327 327
     }
Please login to merge, or discard this patch.
app/Models/Institution_shift.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,12 +68,12 @@
 block discarded – undo
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',['2019','2019/2020']);
71
+            $query->whereIn('institution_shifts.cloned', ['2020']);
72
+        }else {
73
+            $query->whereNotIn('institution_shifts.cloned', ['2019', '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();
Please login to merge, or discard this patch.
app/Models/Institution_class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
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) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             ->groupBy('institution_classes.id')
88 88
             ->get()->toArray();
89 89
             return $data;
90
-        } else {
90
+        }else {
91 91
             $query
92 92
             // ->where('education_programmes.education_cycle_id','<>',4)
93 93
             ->where('institution_shift_id', $shift['id']);
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
         }
99 99
     }
100 100
 
101
-    public static function getGradeClasses($education_grade_id,$institution_id){
101
+    public static function getGradeClasses($education_grade_id, $institution_id) {
102 102
         return self::query()
103
-        ->select('institution_classes.id','institution_classes.institution_id','institution_classes.institution_shift_id',
104
-            'institution_classes.name','institution_classes.no_of_students','institution_classes.class_number','institution_class_grades.education_grade_id')
105
-        ->where('institution_class_grades.education_grade_id',$education_grade_id)
106
-        ->where('institution_classes.institution_id',$institution_id)
107
-        ->join('institution_class_grades','institution_classes.id','institution_class_grades.institution_class_id')
103
+        ->select('institution_classes.id', 'institution_classes.institution_id', 'institution_classes.institution_shift_id',
104
+            'institution_classes.name', 'institution_classes.no_of_students', 'institution_classes.class_number', 'institution_class_grades.education_grade_id')
105
+        ->where('institution_class_grades.education_grade_id', $education_grade_id)
106
+        ->where('institution_classes.institution_id', $institution_id)
107
+        ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id')
108 108
         ->get()->toArray();
109 109
     }
110 110
 
Please login to merge, or discard this patch.
app/Models/Institution_student.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.