Test Setup Failed
Pull Request — master (#478)
by Mohamed
13:16
created
app/Http/Controllers/CloneController.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -28,17 +28,17 @@  discard block
 block discarded – undo
28 28
         $this->academic_period = new Academic_period();
29 29
         $this->institution_classes = new Institution_class();
30 30
         $this->institution_class_subjects = new Institution_class_subject();
31
-        $this->institution_subjects =  new Institution_subject();
32
-        $this->education_grade_subjects =  new Education_grades_subject();
31
+        $this->institution_subjects = new Institution_subject();
32
+        $this->education_grade_subjects = new Education_grades_subject();
33 33
         $this->output = new \Symfony\Component\Console\Output\ConsoleOutput();
34 34
     }
35 35
 
36 36
 
37
-    public function array_walk($shift,$count,$params){
38
-        array_walk($shift,array($this,'process'),$params);
37
+    public function array_walk($shift, $count, $params) {
38
+        array_walk($shift, array($this, 'process'), $params);
39 39
     }
40 40
 
41
-    public function cleanConfig($params){
41
+    public function cleanConfig($params) {
42 42
         $academicPeriod = $params['academic_period'];
43 43
         $this->shifts->where(['academic_period_id' => $academicPeriod->id])->delete();
44 44
         $this->output->writeln('cleaned shifts');
@@ -46,32 +46,32 @@  discard block
 block discarded – undo
46 46
         $this->shifts->where(['cloned' => $academicPeriod->code])->update(['cloned' => $academicPeriod->code - 1]);
47 47
         $this->output->writeln('updated shifts');
48 48
 
49
-        $classIds =  $this->institution_classes->select('id')->where(['academic_period_id' => $academicPeriod->id])->get()->toArray();
49
+        $classIds = $this->institution_classes->select('id')->where(['academic_period_id' => $academicPeriod->id])->get()->toArray();
50 50
         $this->institution_classes->where(['academic_period_id' => $academicPeriod->id])->delete();
51 51
         $this->output->writeln('cleaned classes');
52 52
 
53
-        $this->institution_class_subjects->whereNotIn( 'institution_class_id' , $classIds)->delete();
53
+        $this->institution_class_subjects->whereNotIn('institution_class_id', $classIds)->delete();
54 54
         $this->output->writeln('cleaned subjects');
55 55
 
56
-        do{
57
-          $deleted =  $this->institution_subjects->where('academic_period_id',$academicPeriod->id)->limit(100000)->delete();
56
+        do {
57
+          $deleted = $this->institution_subjects->where('academic_period_id', $academicPeriod->id)->limit(100000)->delete();
58 58
           $this->output->writeln('100000 institutions cleaned shifts');
59
-        }while($deleted > 0);
59
+        } while ($deleted > 0);
60 60
     }
61 61
 
62
-    public function process($shift,$count,$params){
63
-        echo('['.getmypid().']This Process executed at'.date("F d, Y h:i:s A")."\n") ;
62
+    public function process($shift, $count, $params) {
63
+        echo('['.getmypid().']This Process executed at'.date("F d, Y h:i:s A")."\n");
64 64
         $year = $params['year'];
65 65
         $academicPeriod = $params['academic_period'];
66 66
         $previousAcademicPeriod = $params['previous_academic_period'];
67
-        try{
67
+        try {
68 68
             $shiftId = $this->updateShifts($year, $shift);
69 69
             $institutionClasses = $this->institution_classes->getShiftClasses($shift['id']);
70
-            $institutionSubjects = $this->institution_subjects->getInstitutionSubjects($shift['institution_id'],$previousAcademicPeriod->id);
71
-            array_walk($institutionSubjects , array($this,'insertInstitutionSubjects'),$academicPeriod);
72
-            if (!empty($institutionClasses) && !is_null($shiftId) && !is_null($academicPeriod) ) {
70
+            $institutionSubjects = $this->institution_subjects->getInstitutionSubjects($shift['institution_id'], $previousAcademicPeriod->id);
71
+            array_walk($institutionSubjects, array($this, 'insertInstitutionSubjects'), $academicPeriod);
72
+            if (!empty($institutionClasses) && !is_null($shiftId) && !is_null($academicPeriod)) {
73 73
 
74
-                $newInstitutionClasses = $this->generateNewClass($institutionClasses,$shiftId,$academicPeriod->id);
74
+                $newInstitutionClasses = $this->generateNewClass($institutionClasses, $shiftId, $academicPeriod->id);
75 75
 
76 76
                 $params = [
77 77
                     'previous_academic_period_id' => $previousAcademicPeriod->id,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
                     'shift_id' =>$shiftId
80 80
                 ];
81 81
 
82
-                try{
83
-                    array_walk($newInstitutionClasses,array($this,'insertInstitutionClasses'),$params);
82
+                try {
83
+                    array_walk($newInstitutionClasses, array($this, 'insertInstitutionClasses'), $params);
84 84
                     $newInstitutionClasses = $this->institution_classes->getShiftClasses($shiftId);
85 85
                     $this->output->writeln('##########################################################################################################################');
86
-                    $this->output->writeln('updating from '. $shiftId);
86
+                    $this->output->writeln('updating from '.$shiftId);
87 87
 
88
-                }catch (\Exception $e){
88
+                }catch (\Exception $e) {
89 89
                     dd($e);
90
-                     Log::error($e->getMessage(),[$e]);
90
+                     Log::error($e->getMessage(), [$e]);
91 91
                 }
92 92
             }
93 93
 //            DB::commit();
94
-        }catch (\Exception $e){
94
+        }catch (\Exception $e) {
95 95
 //            DB::rollBack();
96
-             Log::error($e->getMessage(),[$e]);
96
+             Log::error($e->getMessage(), [$e]);
97 97
         }
98 98
     }
99 99
 
@@ -103,31 +103,31 @@  discard block
 block discarded – undo
103 103
      * @param $count
104 104
      * @param $academicPeriod
105 105
      */
106
-    public function insertInstitutionSubjects($subjects, $count,$academicPeriod){
107
-       try{
106
+    public function insertInstitutionSubjects($subjects, $count, $academicPeriod) {
107
+       try {
108 108
            $subjects['academic_period_id'] = $academicPeriod->id;
109 109
            $subjects['created'] = now();
110 110
            unset($subjects['total_male_students']);
111 111
            unset($subjects['total_female_students']);
112 112
            unset($subjects['id']);
113 113
            $this->institution_subjects->create($subjects);
114
-       }catch (\Exception $e){
115
-            Log::error($e->getMessage(),[$e]);
114
+       }catch (\Exception $e) {
115
+            Log::error($e->getMessage(), [$e]);
116 116
        }
117 117
     }
118 118
 
119 119
 
120
-    public function  insertInstitutionClasses($class,$count,$param){
121
-            try{
120
+    public function  insertInstitutionClasses($class, $count, $param) {
121
+            try {
122 122
 
123 123
                 $academicPeriod = $param['academic_period_id'];
124 124
                 $educationGrdae = $class['education_grade_id'];
125 125
 
126 126
                 $classId = $class['id'];
127 127
                 unset($class['id']);
128
-                $institutionSubjects = Institution_subject::query()->where('education_grade_id',$class['education_grade_id'])
129
-                    ->where('institution_id',$class['institution_id'])
130
-                    ->where('academic_period_id',$academicPeriod)->get()->toArray();
128
+                $institutionSubjects = Institution_subject::query()->where('education_grade_id', $class['education_grade_id'])
129
+                    ->where('institution_id', $class['institution_id'])
130
+                    ->where('academic_period_id', $academicPeriod)->get()->toArray();
131 131
                 $params = [
132 132
                     'class'=>$class,
133 133
                     'subjects'=>$institutionSubjects,
@@ -140,39 +140,39 @@  discard block
 block discarded – undo
140 140
                 $class['no_of_students'] = $noOfStudents;
141 141
                 $class['created'] = now();
142 142
                 $class['institution_shift_id'] = $param['shift_id'];
143
-                $this->output->writeln('Create class:'. $class['name']);
143
+                $this->output->writeln('Create class:'.$class['name']);
144 144
                 $class = Institution_class::create($class);
145 145
                 $institutionClassGrdaeObj['institution_class_id'] = $class->id;
146 146
                 $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae;
147 147
                 Institution_class_grade::create($institutionClassGrdaeObj);
148
-                $institutionSubjects = Institution_subject::query()->where('education_grade_id',$educationGrdae)
149
-                    ->where('institution_id',$class->institution_id)
150
-                    ->where('academic_period_id',$academicPeriod)
148
+                $institutionSubjects = Institution_subject::query()->where('education_grade_id', $educationGrdae)
149
+                    ->where('institution_id', $class->institution_id)
150
+                    ->where('academic_period_id', $academicPeriod)
151 151
                     ->groupBy('education_subject_id')
152 152
                     ->get()
153 153
                     ->toArray();
154 154
                 $params['class'] = $class;
155
-                $this->insertInstitutionClassSubjects($institutionSubjects,$class);
155
+                $this->insertInstitutionClassSubjects($institutionSubjects, $class);
156 156
 //                array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params);
157
-            }catch (\Exception $e){
158
-                 Log::error($e->getMessage(),[$e]);
157
+            }catch (\Exception $e) {
158
+                 Log::error($e->getMessage(), [$e]);
159 159
             }
160 160
     }
161 161
 
162
-    public function insertInstitutionClassSubjects($subjects,$class){
163
-        if(!empty($subjects)){
164
-            try{
165
-                array_walk($subjects,array($this,'insertClassSubjects'),$class);
166
-                $this->output->writeln('updating subjects '. $class->name);
167
-            }catch (\Exception $e){
168
-                 Log::error($e->getMessage(),[$e]);
162
+    public function insertInstitutionClassSubjects($subjects, $class) {
163
+        if (!empty($subjects)) {
164
+            try {
165
+                array_walk($subjects, array($this, 'insertClassSubjects'), $class);
166
+                $this->output->writeln('updating subjects '.$class->name);
167
+            }catch (\Exception $e) {
168
+                 Log::error($e->getMessage(), [$e]);
169 169
             }
170 170
         };
171 171
     }
172 172
 
173 173
   
174
-    public function insertClassSubjects($subject,$count,$newClassId){
175
-        try{
174
+    public function insertClassSubjects($subject, $count, $newClassId) {
175
+        try {
176 176
             $subjectobj['status'] = 1;
177 177
             $subjectobj['created_user_id'] = 1;
178 178
             $subjectobj['created'] = now();
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
             $subjectobj['institution_class_id'] = $newClassId->id;
181 181
             $subjectobj['institution_subject_id'] = $subject['id'];
182 182
 
183
-            if(!$this->institution_class_subjects->isDuplicated($subjectobj)){
183
+            if (!$this->institution_class_subjects->isDuplicated($subjectobj)) {
184 184
                 $this->institution_class_subjects->create($subjectobj);
185 185
             }
186
-        }catch (\Exception $e){
187
-             Log::error($e->getMessage(),[$e]);
186
+        }catch (\Exception $e) {
187
+             Log::error($e->getMessage(), [$e]);
188 188
         }
189 189
     }
190 190
 
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
      * @param $academicPeriod
197 197
      * @return array
198 198
      */
199
-    public function generateNewClass($classes,$shiftId,$academicPeriod){
199
+    public function generateNewClass($classes, $shiftId, $academicPeriod) {
200 200
         $newClasses = [];
201
-        foreach ( $classes as $class) {
201
+        foreach ($classes as $class) {
202 202
             $noOfStudents = $class['no_of_students'] == 0 ? 40 : $class['no_of_students'];
203 203
             $class['academic_period_id'] = $academicPeriod;
204 204
             $class['no_of_students'] = $noOfStudents;
205 205
             $class['created'] = now();
206 206
             $class['institution_shift_id'] = $shiftId;
207
-            array_push($newClasses,$class);
207
+            array_push($newClasses, $class);
208 208
         }
209 209
         return $newClasses;
210 210
     }
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
      * @param $shift
216 216
      * @return mixed
217 217
      */
218
-    public function updateShifts($year,$shift){
218
+    public function updateShifts($year, $shift) {
219 219
         $academicPeriod = $this->academic_period->getAcademicPeriod($year);
220
-        $this->shifts->where('id',$shift['id'])->update(['cloned' => $year]);
220
+        $this->shifts->where('id', $shift['id'])->update(['cloned' => $year]);
221 221
         $shift['academic_period_id'] = $academicPeriod->id;
222 222
         $exist = $this->shifts->shiftExists($shift);
223
-        return $this->shifts->create((array)$shift)->id;
223
+        return $this->shifts->create((array) $shift)->id;
224 224
     }
225 225
 }
Please login to merge, or discard this patch.
app/Console/Commands/UpdateStudentsCount.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
     public function handle()
49 49
     {
50 50
         $this->output->writeln('#########################################');
51
-        if($this->argument('entity') == 'class'){
51
+        if ($this->argument('entity') == 'class') {
52 52
             $classes = Institution_class::get()->toArray();
53
-            $func = array($this,'updateCount');
54
-            array_walk($subjects,array($this,'process'));
55
-            $this->output->writeln('start updating:'. count($classes));
56
-        }elseif($this->argument('entity') == 'subject'){
53
+            $func = array($this, 'updateCount');
54
+            array_walk($subjects, array($this, 'process'));
55
+            $this->output->writeln('start updating:'.count($classes));
56
+        }elseif ($this->argument('entity') == 'subject') {
57 57
             $subjects = Institution_subject::get()->toArray(); 
58
-            $subjects = array_chunk($subjects,10000);
59
-            $this->output->writeln('start updating:'. count($subjects));
60
-            array_walk($subjects,array($this,'process'));
58
+            $subjects = array_chunk($subjects, 10000);
59
+            $this->output->writeln('start updating:'.count($subjects));
60
+            array_walk($subjects, array($this, 'process'));
61 61
             $this->output->writeln('#########################################');
62 62
         }
63 63
        
64 64
     }
65 65
 
66
-    public function process($data){
67
-        if($this->argument('entity') == 'class'){
68
-            $func = array($this,'updateCount');
69
-            processParallel($func,$data,$this->argument('max'));
70
-            $this->output->writeln('start updating calss count:'. count($data));
71
-        }elseif($this->argument('entity') == 'subject'){
72
-            $this->output->writeln('start updating subject count:'. count($data));
73
-            $func_subject = array($this,'updateSubjectCount');
74
-            processParallel($func_subject,$data,$this->argument('max'));
66
+    public function process($data) {
67
+        if ($this->argument('entity') == 'class') {
68
+            $func = array($this, 'updateCount');
69
+            processParallel($func, $data, $this->argument('max'));
70
+            $this->output->writeln('start updating calss count:'.count($data));
71
+        }elseif ($this->argument('entity') == 'subject') {
72
+            $this->output->writeln('start updating subject count:'.count($data));
73
+            $func_subject = array($this, 'updateSubjectCount');
74
+            processParallel($func_subject, $data, $this->argument('max'));
75 75
         }
76 76
     }
77 77
 
78
-    public function updateCount($class){
79
-        $this->output->writeln('updating class:'. $class['id']);
80
-        $totalStudents =  Institution_class_student::getStudentsCount($class['id']);
78
+    public function updateCount($class) {
79
+        $this->output->writeln('updating class:'.$class['id']);
80
+        $totalStudents = Institution_class_student::getStudentsCount($class['id']);
81 81
         Institution_class::where('id', '=', $class['id'])
82 82
         ->update([
83 83
             'total_male_students' => $totalStudents['total_male_students'],
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
         ]);
86 86
     }
87 87
 
88
-    public function updateSubjectCount($subject){
89
-        $this->output->writeln('updating subject:'. $subject['id']);
88
+    public function updateSubjectCount($subject) {
89
+        $this->output->writeln('updating subject:'.$subject['id']);
90 90
         $totalStudents = Institution_subject_student::getStudentsCount($subject['id']);
91 91
         Institution_subject::where(['id' => $subject['id']])
92 92
             ->update([
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $func = array($this,'updateCount');
54 54
             array_walk($subjects,array($this,'process'));
55 55
             $this->output->writeln('start updating:'. count($classes));
56
-        }elseif($this->argument('entity') == 'subject'){
56
+        } elseif($this->argument('entity') == 'subject'){
57 57
             $subjects = Institution_subject::get()->toArray(); 
58 58
             $subjects = array_chunk($subjects,10000);
59 59
             $this->output->writeln('start updating:'. count($subjects));
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $func = array($this,'updateCount');
69 69
             processParallel($func,$data,$this->argument('max'));
70 70
             $this->output->writeln('start updating calss count:'. count($data));
71
-        }elseif($this->argument('entity') == 'subject'){
71
+        } elseif($this->argument('entity') == 'subject'){
72 72
             $this->output->writeln('start updating subject count:'. count($data));
73 73
             $func_subject = array($this,'updateSubjectCount');
74 74
             processParallel($func_subject,$data,$this->argument('max'));
Please login to merge, or discard this patch.
app/Console/Commands/ImportStudents.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
             ->join('contact_types', 'user_contacts.contact_type_id', '=', 'contact_types.id')
139 139
             //only for UAT
140 140
             //  ->where('contact_types.contact_option_id', '=', 5)
141
-           ->where('contact_types.contact_option_id', '!=', 5)
141
+            ->where('contact_types.contact_option_id', '!=', 5)
142 142
             //  ->where('contact_types.name', '=', 'TestEmail')
143 143
             ->limit(1)
144 144
             ->get()->toArray();
Please login to merge, or discard this patch.
app/Console/Commands/CloneConfigData.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@
 block discarded – undo
61 61
         // dd($shift);
62 62
         $function = array($this->clone, 'process');
63 63
         // array_walk($shift,$function,$params);
64
-        processParallel($function,$shift, $this->argument('max'),$params);
64
+        processParallel($function, $shift, $this->argument('max'), $params);
65 65
         $this->end_time = microtime(TRUE);
66 66
 
67 67
 
68 68
         $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$');
69
-        $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete');
69
+        $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete');
70 70
         $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$');
71 71
     }  
72 72
 }
Please login to merge, or discard this patch.
app/Console/Commands/CleanExamData.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,11 +85,11 @@
 block discarded – undo
85 85
 
86 86
     public function process($students){
87 87
         $type = $this->argument('type');
88
-       if($type == 'duplication'){
88
+        if($type == 'duplication'){
89 89
         array_walk($students,array($this,'cleanData'));
90
-       }elseif($type == 'invalid' || 'all'){
90
+        }elseif($type == 'invalid' || 'all'){
91 91
         array_walk($students,array($this,'cleanInvalidData'));
92
-       }
92
+        }
93 93
     }
94 94
 
95 95
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $type = $this->argument('type');
50 50
         $students = array();
51
-        if($type == 'invalid'){
51
+        if ($type == 'invalid') {
52 52
             $students = DB::table('examination_students as es')
53 53
             ->whereRaw('CHAR_LENGTH(nsid) > 11')
54 54
             ->get()
55 55
             ->toArray();
56
-        }elseif($type == 'duplicate'){
56
+        }elseif ($type == 'duplicate') {
57 57
             $students = DB::table('institution_students as is')
58 58
             ->join('security_users as su', 'su.id', 'is.student_id')
59 59
             ->where('is.updated_from', 'doe')
@@ -63,39 +63,39 @@  discard block
 block discarded – undo
63 63
             ->get()
64 64
             ->toArray();
65 65
             
66
-        }elseif('all'){
66
+        }elseif ('all') {
67 67
             $students = DB::table('examination_students')
68
-            ->where('nsid','<>','')
68
+            ->where('nsid', '<>', '')
69 69
             ->whereNotNull('nsid')
70 70
             ->get()
71 71
             ->toArray();
72 72
         }
73 73
 
74 74
         $this->output->writeln('###########################################------Start cleanning exam records------###########################################');    
75
-        if(count($students) > 0){
76
-            $this->output->writeln('Total students to clean: '.  count($students));
75
+        if (count($students) > 0) {
76
+            $this->output->writeln('Total students to clean: '.count($students));
77 77
             $students = array_chunk($students, $this->argument('chunk'));
78 78
             $function = array($this, 'process');
79
-            processParallel($function,$students, $this->argument('max'));
80
-        }else{
79
+            processParallel($function, $students, $this->argument('max'));
80
+        }else {
81 81
             $this->output->writeln('nothing to process, all are cleaned');
82 82
         }   
83 83
         $this->output->writeln('###########################################------Finished cleaning exam records------###########################################');
84 84
     }
85 85
 
86
-    public function process($students){
86
+    public function process($students) {
87 87
         $type = $this->argument('type');
88
-       if($type == 'duplication'){
89
-        array_walk($students,array($this,'cleanData'));
90
-       }elseif($type == 'invalid' || 'all'){
91
-        array_walk($students,array($this,'cleanInvalidData'));
88
+       if ($type == 'duplication') {
89
+        array_walk($students, array($this, 'cleanData'));
90
+       }elseif ($type == 'invalid' || 'all') {
91
+        array_walk($students, array($this, 'cleanInvalidData'));
92 92
        }
93 93
     }
94 94
 
95 95
 
96 96
     public function cleanData($Student)
97 97
     {
98
-        $exist = Examination_student::where('nsid','=',  $Student->openemis_no)->count();
98
+        $exist = Examination_student::where('nsid', '=', $Student->openemis_no)->count();
99 99
 
100 100
         if (!$exist) {
101 101
             Institution_student::where('student_id', $Student->student_id)->delete();
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
     public function cleanInvalidData($Student)
109 109
     {
110 110
         $Student = (array) $Student;
111
-        $exist = Examination_student::where('nsid',$Student['nsid'])->count();
111
+        $exist = Examination_student::where('nsid', $Student['nsid'])->count();
112 112
         
113 113
         $this->uniqueUId = new UniqueUid();
114 114
 
115
-        $nsid = ltrim(rtrim($Student['nsid'],'-'),'-');
116
-        if(!$this->uniqueUId::isValidUniqueId('DBY-898-3J2')){
115
+        $nsid = ltrim(rtrim($Student['nsid'], '-'), '-');
116
+        if (!$this->uniqueUId::isValidUniqueId('DBY-898-3J2')) {
117 117
         }
118 118
     }
119 119
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             ->whereRaw('CHAR_LENGTH(nsid) > 11')
54 54
             ->get()
55 55
             ->toArray();
56
-        }elseif($type == 'duplicate'){
56
+        } elseif($type == 'duplicate'){
57 57
             $students = DB::table('institution_students as is')
58 58
             ->join('security_users as su', 'su.id', 'is.student_id')
59 59
             ->where('is.updated_from', 'doe')
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             ->get()
64 64
             ->toArray();
65 65
             
66
-        }elseif('all'){
66
+        } elseif('all'){
67 67
             $students = DB::table('examination_students')
68 68
             ->where('nsid','<>','')
69 69
             ->whereNotNull('nsid')
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             $students = array_chunk($students, $this->argument('chunk'));
78 78
             $function = array($this, 'process');
79 79
             processParallel($function,$students, $this->argument('max'));
80
-        }else{
80
+        } else{
81 81
             $this->output->writeln('nothing to process, all are cleaned');
82 82
         }   
83 83
         $this->output->writeln('###########################################------Finished cleaning exam records------###########################################');
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $type = $this->argument('type');
88 88
        if($type == 'duplication'){
89 89
         array_walk($students,array($this,'cleanData'));
90
-       }elseif($type == 'invalid' || 'all'){
90
+       } elseif($type == 'invalid' || 'all'){
91 91
         array_walk($students,array($this,'cleanInvalidData'));
92 92
        }
93 93
     }
Please login to merge, or discard this patch.
app/Console/Commands/StudentsIdGen.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $this->output = new \Symfony\Component\Console\Output\ConsoleOutput();
37 37
         $this->students = new Security_user();
38 38
         $this->uniqueUId = new UniqueUid();
39
-        $this->max  = 0;
39
+        $this->max = 0;
40 40
         $this->child = 0;
41 41
         parent::__construct();
42 42
     }
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
     public function processParallel(array $arr, $procs = 4)
61 61
     {
62 62
         // Break array up into $procs chunks.
63
-        $chunks   = array_chunk($arr, ceil((count($arr) / $procs)));
63
+        $chunks   = array_chunk($arr, ceil((count($arr)/$procs)));
64 64
         $pid      = -1;
65 65
         $children = array();
66 66
         foreach ($chunks as $items) {
67 67
             $pid = pcntl_fork();
68 68
             if ($pid === -1) {
69 69
                 die('could not fork');
70
-            } else if ($pid === 0) {
71
-                $this->output->writeln('started processes: ' . count($children));
70
+            }else if ($pid === 0) {
71
+                $this->output->writeln('started processes: '.count($children));
72 72
                 // We are the child process. Pass a chunk of items to process.
73 73
                 array_walk($items, array($this, 'process'));
74 74
                 exit(0);
75
-            } else {
75
+            }else {
76 76
                 // We are the parent.
77 77
                 $children[] = $pid;
78 78
             }
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 
105 105
                 $newId = $this->uniqueUId::getUniqueAlphanumeric();
106 106
                 $student['openemis_no'] = $newId;
107
-                $student =  $this->uniqueUserId->updateOrInsertRecord($student);
107
+                $student = $this->uniqueUserId->updateOrInsertRecord($student);
108 108
                 // $this->output->writeln('New NSID generated for :' . $student['id']);
109 109
                 Security_user::query()->where('id', $student['id'])
110 110
                     ->update(['openemis_no' => $newId, 'username' => str_replace('-', '', $newId)]);
111
-            } catch (\Exception $e) {
111
+            }catch (\Exception $e) {
112 112
             }
113
-        } else {
113
+        }else {
114 114
             try {
115 115
                 // $this->output->writeln('Updating student:' . $student['id']);
116 116
                 $this->uniqueUserId->updateOrInsertRecord($student);
117
-            } catch (\Exception $e) {
117
+            }catch (\Exception $e) {
118 118
                 dd($e);
119 119
             }
120 120
         }
Please login to merge, or discard this patch.
app/Models/Unique_user_id.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     public  function updateOrInsertRecord($user)
56 56
     {
57
-       try {
57
+        try {
58 58
             // regenerate unique id if it's not available
59 59
         $uniqueId =  $this->uniqueUserId::isValidUniqueId($user['openemis_no'],9) ? $this->uniqueUserId::getUniqueAlphanumeric() : $user['openemis_no'];
60 60
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
             ]);
70 70
         }
71 71
         return $user;
72
-       } catch (\Exception $th) {
73
-           $user['openemis_no'] = $this->uniqueUserId::getUniqueAlphanumeric();
74
-           $this->updateOrInsertRecord($user);
75
-       }
72
+        } catch (\Exception $th) {
73
+            $user['openemis_no'] = $this->uniqueUserId::getUniqueAlphanumeric();
74
+            $this->updateOrInsertRecord($user);
75
+        }
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     {
57 57
        try {
58 58
             // regenerate unique id if it's not available
59
-        $uniqueId =  $this->uniqueUserId::isValidUniqueId($user['openemis_no'],9) ? $this->uniqueUserId::getUniqueAlphanumeric() : $user['openemis_no'];
59
+        $uniqueId = $this->uniqueUserId::isValidUniqueId($user['openemis_no'], 9) ? $this->uniqueUserId::getUniqueAlphanumeric() : $user['openemis_no'];
60 60
 
61 61
         //check if the user's entry exits ?
62
-        $exists = Unique_user_id::where('unique_id' , $uniqueId)->exists();
62
+        $exists = Unique_user_id::where('unique_id', $uniqueId)->exists();
63 63
 
64 64
         if (!$exists) {
65 65
             // try to feed unique user id
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             ]);
70 70
         }
71 71
         return $user;
72
-       } catch (\Exception $th) {
72
+       }catch (\Exception $th) {
73 73
            $user['openemis_no'] = $this->uniqueUserId::getUniqueAlphanumeric();
74 74
            $this->updateOrInsertRecord($user);
75 75
        }
Please login to merge, or discard this patch.
app/Models/Institution_subject.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Illuminate\Database\Eloquent\Model;
6 6
 
7
-class Institution_subject extends Base_Model  {
7
+class Institution_subject extends Base_Model {
8 8
 
9 9
     /**
10 10
      * The database table used by the model.
@@ -42,42 +42,42 @@  discard block
 block discarded – undo
42 42
     protected $dates = ['modified', 'created', 'modified', 'created'];
43 43
 
44 44
 
45
-    public  function institutionGradeSubject(){
46
-        return $this->belongsTo('App\Models\Education_grades_subject','education_subject_id','education_subject_id');
45
+    public  function institutionGradeSubject() {
46
+        return $this->belongsTo('App\Models\Education_grades_subject', 'education_subject_id', 'education_subject_id');
47 47
     }
48 48
 
49
-    public  function institutionOptionalGradeSubject(){
50
-        return $this->belongsTo('App\Models\Education_grades_subject','education_grade_id','education_grade_id');
49
+    public  function institutionOptionalGradeSubject() {
50
+        return $this->belongsTo('App\Models\Education_grades_subject', 'education_grade_id', 'education_grade_id');
51 51
     }
52 52
 
53
-    public  function institutionMandatoryGradeSubject(){
54
-        return $this->belongsTo('App\Models\Education_grades_subject','education_grade_id','education_grade_id');
53
+    public  function institutionMandatoryGradeSubject() {
54
+        return $this->belongsTo('App\Models\Education_grades_subject', 'education_grade_id', 'education_grade_id');
55 55
     }
56 56
 
57 57
 
58
-    public  function institutionClassSubject(){
59
-        return $this->hasMany('App\Models\Institution_class_subject','institution_class_id','id');
58
+    public  function institutionClassSubject() {
59
+        return $this->hasMany('App\Models\Institution_class_subject', 'institution_class_id', 'id');
60 60
     }
61 61
 
62 62
 
63 63
 
64
-    public function getInstitutionSubjects($institution_id,$academic_period_id){
65
-        return self::query()->where('institution_id',$institution_id)
66
-            ->where('academic_period_id',$academic_period_id)
64
+    public function getInstitutionSubjects($institution_id, $academic_period_id) {
65
+        return self::query()->where('institution_id', $institution_id)
66
+            ->where('academic_period_id', $academic_period_id)
67 67
             ->get()->toArray();
68 68
     }
69 69
 
70 70
     public  static function getStudentsCount($institution_subject_id)
71 71
     {
72
-        $total_male_students = self::with(['student' => function ($query) {
72
+        $total_male_students = self::with(['student' => function($query) {
73 73
             $query->where('student.gender_id', '=', 1);
74
-        }])->whereHas('student', function ($query) {
74
+        }])->whereHas('student', function($query) {
75 75
             $query->where('gender_id', '=', 1);
76 76
         })->where('institution_subject_id', '=', $institution_subject_id)->count();
77 77
 
78
-        $total_female_students = self::with(['student' => function ($query) {
78
+        $total_female_students = self::with(['student' => function($query) {
79 79
             $query->where('student.gender_id', '=', 2);
80
-        }])->whereHas('student', function ($query) {
80
+        }])->whereHas('student', function($query) {
81 81
             $query->where('gender_id', '=', 2);
82 82
         })->where('institution_subject_id', '=', $institution_subject_id)->count();
83 83
 
Please login to merge, or discard this patch.
app/Models/Security_user.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
     public function getMatches($student)
150 150
     {
151 151
         return $this
152
-        ->where('gender_id',$student['gender'] + 1)
153
-        ->where('institutions.code',$student['schoolid'])
154
-        ->where('date_of_birth',$student['b_date'])
152
+        ->where('gender_id', $student['gender'] + 1)
153
+        ->where('institutions.code', $student['schoolid'])
154
+        ->where('date_of_birth', $student['b_date'])
155 155
             ->join('institution_students', 'security_users.id', 'institution_students.student_id')
156 156
             ->join('institutions', 'institution_students.institution_id', 'institutions.id')
157 157
             ->get()->toArray();
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
     public function getStudentCount($student)
167 167
     {
168 168
         return $this
169
-        ->where('gender_id',$student['gender'] + 1)
170
-        ->where('institutions.code',$student['schoolid'])
171
-        ->where('date_of_birth',$student['b_date'])
169
+        ->where('gender_id', $student['gender'] + 1)
170
+        ->where('institutions.code', $student['schoolid'])
171
+        ->where('date_of_birth', $student['b_date'])
172 172
             ->join('institution_students', 'security_users.id', 'institution_students.student_id')
173 173
             ->join('institutions', 'institution_students.institution_id', 'institutions.id')
174 174
             ->count();
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             $id = $this->insertGetId($studentData);
203 203
             $studentData['id'] = $id;
204 204
             return $studentData;
205
-        } catch (\Exception $th) {
205
+        }catch (\Exception $th) {
206 206
             Log::error($th->getMessage());
207 207
             // in case of duplication of the Unique ID this will recursive.
208 208
             $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric();
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         $this->uniqueUserId = new Unique_user_id();
224 224
         $this->uniqueUId = new UniqueUid();
225 225
         // regenerate unique id if it's not available
226
-        $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'],9)) ?  $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric();
226
+        $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric();
227 227
 
228 228
         $studentData = [
229 229
             'username' => str_replace('-', '', $uniqueId),
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 
239 239
         try {
240 240
             $this->uniqueUserId->updateOrInsertRecord($studentData);
241
-            self::where( 'id'  , $sis_student['student_id'])->update($studentData);
241
+            self::where('id', $sis_student['student_id'])->update($studentData);
242 242
             $studentData['id'] = $sis_student['student_id'];
243 243
             return $studentData;
244
-        } catch (\Exception $th) {
244
+        }catch (\Exception $th) {
245 245
             Log::error($th);
246 246
             // in case of duplication of the Unique ID this will recursive.
247 247
             $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric();
Please login to merge, or discard this patch.