Test Setup Failed
Pull Request — master (#620)
by Mohamed
08:18
created
app/Models/Institution_class_student.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public static function boot()
59 59
     {
60 60
         parent::boot();
61
-        self::creating(function ($model) {
61
+        self::creating(function($model) {
62 62
             $model->id = (string) Uuid::generate(4);
63 63
             $model->created = now();
64 64
         });
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 
72 72
     public  static function getStudentsCount($institution_class_id)
73 73
     {
74
-        $total_male_students = self::with(['student' => function ($query) {
74
+        $total_male_students = self::with(['student' => function($query) {
75 75
             $query->where('student.gender_id', '=', 1);
76
-        }])->whereHas('student', function ($query) {
76
+        }])->whereHas('student', function($query) {
77 77
             $query->where('gender_id', '=', 1);
78 78
         })->where('institution_class_id', '=', $institution_class_id)->count();
79 79
 
80
-        $total_female_students = self::with(['student' => function ($query) {
80
+        $total_female_students = self::with(['student' => function($query) {
81 81
             $query->where('student.gender_id', '=', 2);
82
-        }])->whereHas('student', function ($query) {
82
+        }])->whereHas('student', function($query) {
83 83
             $query->where('gender_id', '=', 2);
84 84
         })->where('institution_class_id', '=', $institution_class_id)->count();
85 85
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
             ->where('student_id', $student['student_id'])
110 110
             ->join('institution_classes', 'institution_class_students.institution_class_id', '=', 'institution_classes.id')
111 111
             ->where('institution_class_students.student_id', $student['student_id'])
112
-            ->where('institution_class_students.academic_period_id',$student['academic_period_id'])
113
-            ->where('institution_class_students.institution_id',$student['institution_id'])
112
+            ->where('institution_class_students.academic_period_id', $student['academic_period_id'])
113
+            ->where('institution_class_students.institution_id', $student['institution_id'])
114 114
             ->whereNull('institution_class_students.deleted_at')
115 115
             ->get()->first();
116 116
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 'institution_id' => $admissionInfo['instituion']->id,
135 135
                 'student_status_id' => 1
136 136
             ]);
137
-        } catch (\Throwable $th) {
137
+        }catch (\Throwable $th) {
138 138
             Log::error($th);
139 139
         }
140 140
     }
Please login to merge, or discard this patch.
app/Models/Institution_grade.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             })
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             ->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
             ->orderBy('institution_id')
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
             ->toArray();
168 168
     }
169 169
 
170
-    public function getGradeSubjects($institutionId){
170
+    public function getGradeSubjects($institutionId) {
171 171
         return self::query()
172
-        ->select('institution_grades.institution_id','education_grades_subjects.education_grade_id','education_grades_subjects.education_subject_id','education_subjects.name')
173
-        ->where('institution_grades.institution_id',$institutionId)
172
+        ->select('institution_grades.institution_id', 'education_grades_subjects.education_grade_id', 'education_grades_subjects.education_subject_id', 'education_subjects.name')
173
+        ->where('institution_grades.institution_id', $institutionId)
174 174
         ->join('education_grades', 'institution_grades.education_grade_id', 'education_grades.id')
175
-        ->join('education_grades_subjects','education_grades.id','education_grades_subjects.education_grade_id')
176
-        ->join('education_subjects','education_grades_subjects.education_subject_id','education_subjects.id')
175
+        ->join('education_grades_subjects', 'education_grades.id', 'education_grades_subjects.education_grade_id')
176
+        ->join('education_subjects', 'education_grades_subjects.education_subject_id', 'education_subjects.id')
177 177
         ->groupBy('education_grades_subjects.id')
178 178
         ->get()
179 179
         ->toArray();
Please login to merge, or discard this patch.
app/Models/Institution_class_subject.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Illuminate\Database\Eloquent\Model;
6 6
 use Webpatser\Uuid\Uuid;
7 7
 
8
-class Institution_class_subject extends Base_Model  {
8
+class Institution_class_subject extends Base_Model {
9 9
 
10 10
     /**
11 11
      * The database table used by the model.
@@ -42,19 +42,19 @@  discard block
 block discarded – undo
42 42
      */
43 43
     protected $dates = ['modified', 'created'];
44 44
 
45
-    public function institutionMandatorySubject(){
46
-        return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id')
45
+    public function institutionMandatorySubject() {
46
+        return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id')
47 47
         ->with('institutionGradeSubject')
48
-        ->whereHas('institutionGradeSubject', function ($query) {
49
-                $query->where('auto_allocation',1);
48
+        ->whereHas('institutionGradeSubject', function($query) {
49
+                $query->where('auto_allocation', 1);
50 50
         });
51 51
     }
52 52
 
53
-    public function institutionOptionalSubject(){
54
-        return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id')
53
+    public function institutionOptionalSubject() {
54
+        return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id')
55 55
         ->with('institutionGradeSubject')
56
-        ->whereHas('institutionGradeSubject', function ($query) {
57
-                $query->where('auto_allocation',0);
56
+        ->whereHas('institutionGradeSubject', function($query) {
57
+                $query->where('auto_allocation', 0);
58 58
         });
59 59
 
60 60
     }
@@ -62,23 +62,23 @@  discard block
 block discarded – undo
62 62
     public static function boot()
63 63
     {
64 64
         parent::boot();
65
-        self::creating(function ($model) {
65
+        self::creating(function($model) {
66 66
             $model->id = (string) Uuid::generate(4);
67 67
         });
68 68
     }
69 69
 
70
-    public function institutionSubject(){
71
-        return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id')
70
+    public function institutionSubject() {
71
+        return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id')
72 72
         ->with('institutionGradeSubject');
73 73
     }
74 74
 
75 75
 
76
-    public static function getMandetorySubjects($institutionClass){
76
+    public static function getMandetorySubjects($institutionClass) {
77 77
         $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass)->first();
78 78
         $mandatorySubject = Institution_class_subject::with(['institutionSubject'])
79
-            ->whereHas('institutionSubject', function ($query) use ($institutionGrade) {
80
-                $query->whereHas('institutionGradeSubject',function($query){
81
-                    $query->where('auto_allocation',1);
79
+            ->whereHas('institutionSubject', function($query) use ($institutionGrade) {
80
+                $query->whereHas('institutionGradeSubject', function($query) {
81
+                    $query->where('auto_allocation', 1);
82 82
                 })->where('education_grade_id', $institutionGrade->education_grade_id);
83 83
                 // ->where('auto_allocation', $institutionGrade->education_grade_id);
84 84
             })
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
         return $mandatorySubject;
88 88
     }
89 89
 
90
-    public static function getAllSubjects($institutionClass){
90
+    public static function getAllSubjects($institutionClass) {
91 91
         $allSubjects = Institution_class_subject::with(['institutionSubject'])
92
-        ->whereHas('institutionSubject', function ($query) use ($institutionClass) {
92
+        ->whereHas('institutionSubject', function($query) use ($institutionClass) {
93 93
             $query->whereHas('institutionGradeSubject')->where('education_grade_id', $institutionClass['education_grade_id']);
94 94
         })
95 95
         ->where('institution_class_id', '=', $institutionClass['id'])
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
         $data = [];
102 102
         foreach ($subjects as $subject) {
103 103
             $subjectId = Institution_class_subject::with(['institutionSubject'])
104
-                ->whereHas('institutionSubject', function ($query) use ($row, $subject, $student) {
105
-                    $query->whereHas('institutionGradeSubject',function($query){
106
-                        $query->where('auto_allocation',0);
104
+                ->whereHas('institutionSubject', function($query) use ($row, $subject, $student) {
105
+                    $query->whereHas('institutionGradeSubject', function($query) {
106
+                        $query->where('auto_allocation', 0);
107 107
                     })
108 108
                         ->where('name', '=', $row[$subject])
109 109
                         ->where('education_grade_id', '=', $student->education_grade_id);
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
         return $data;
117 117
     }
118 118
 
119
-    public function getInstitutionClassSubjects($academicPeriodId,$classIds){
119
+    public function getInstitutionClassSubjects($academicPeriodId, $classIds) {
120 120
         return self::query()
121
-            ->whereIn('institution_class_id',$classIds)
121
+            ->whereIn('institution_class_id', $classIds)
122 122
             ->get()
123 123
             ->toArray();
124 124
     }
125 125
 
126
-    public function isDuplicated($subject){
127
-        return self::query()->where('institution_subject_id',$subject['institution_subject_id'])
128
-            ->where('institution_class_id',$subject['institution_class_id'])->get()->toArray();
126
+    public function isDuplicated($subject) {
127
+        return self::query()->where('institution_subject_id', $subject['institution_subject_id'])
128
+            ->where('institution_class_id', $subject['institution_class_id'])->get()->toArray();
129 129
     }
130 130
 }
Please login to merge, or discard this patch.
app/Http/Controllers/BulkPromotion.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             dd($e);
221 221
             Log::error($e->getMessage());
222 222
         }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $studentClass = $this->institution_class_students->getStudentNewClass($student);
238 238
         if (!is_null($studentClass)) {
239 239
             return  array_search(str_replace($educationGrade['name'], $nextGrade->name, $studentClass->name), array_column($classes, 'name'));
240
-        } else {
240
+        }else {
241 241
             return false;
242 242
         }
243 243
     }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         $class = null;
260 260
         if (count($classes) == 1) {
261 261
             $class = $classes[0];
262
-        } else {
262
+        }else {
263 263
             $class = $this->getStudentClass($student, $educationGrade, $nextGrade, $classes);
264 264
             if (is_numeric($class)) {
265 265
                 $class = $classes[$class];
@@ -288,16 +288,16 @@  discard block
 block discarded – undo
288 288
                         $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects);
289 289
                         $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id');
290 290
                         array_walk($allSubjects, array($this, 'insertSubject'));
291
-                        array_walk($allInsSubjects,array($this,'updateSubjectCount'));
291
+                        array_walk($allInsSubjects, array($this, 'updateSubjectCount'));
292 292
                     }
293 293
                     $output = new \Symfony\Component\Console\Output\ConsoleOutput();
294
-                    $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']);
295
-                } else {
296
-                    $this->institution_class_students->where('id', (string)$student['id'])->update($studentObj);
294
+                    $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']);
295
+                }else {
296
+                    $this->institution_class_students->where('id', (string) $student['id'])->update($studentObj);
297 297
                     $output = new \Symfony\Component\Console\Output\ConsoleOutput();
298
-                    $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']);
298
+                    $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']);
299 299
                 }
300
-            } catch (\Exception $e) {
300
+            }catch (\Exception $e) {
301 301
                 dd($e);
302 302
             }
303 303
         }
Please login to merge, or discard this patch.