Test Setup Failed
Pull Request — master (#465)
by Mohamed
07:14
created
app/Libraries/ShaHash/SHAHasher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function check($value, $hashedValue, array $options = [])
15 15
     {
16
-        return password_verify ($value , $hashedValue);
16
+        return password_verify($value, $hashedValue);
17 17
     }
18 18
 
19 19
 
20 20
     public function make($value, array $options = [])
21 21
     {
22
-        return password_hash($value,PASSWORD_DEFAULT,$options);
22
+        return password_hash($value, PASSWORD_DEFAULT, $options);
23 23
     }
24 24
 
25 25
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function needsRehash($hashedValue, array $options = [])
29 29
     {
30
-        return password_needs_rehash($hashedValue,$options);
30
+        return password_needs_rehash($hashedValue, $options);
31 31
     }
32 32
 
33 33
 
Please login to merge, or discard this patch.
app/Models/Institution_class_student.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public static function boot()
54 54
     {
55 55
         parent::boot();
56
-        self::creating(function ($model) {
56
+        self::creating(function($model) {
57 57
             $model->id = (string) Uuid::generate(4);
58 58
             $model->created = now();
59 59
         });
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
 
67 67
     public  static function getStudentsCount($institution_class_id)
68 68
     {
69
-        $total_male_students = self::with(['student' => function ($query) {
69
+        $total_male_students = self::with(['student' => function($query) {
70 70
             $query->where('student.gender_id', '=', 1);
71
-        }])->whereHas('student', function ($query) {
71
+        }])->whereHas('student', function($query) {
72 72
             $query->where('gender_id', '=', 1);
73 73
         })->where('institution_class_id', '=', $institution_class_id)->count();
74 74
 
75
-        $total_female_students = self::with(['student' => function ($query) {
75
+        $total_female_students = self::with(['student' => function($query) {
76 76
             $query->where('student.gender_id', '=', 2);
77
-        }])->whereHas('student', function ($query) {
77
+        }])->whereHas('student', function($query) {
78 78
             $query->where('gender_id', '=', 2);
79 79
         })->where('institution_class_id', '=', $institution_class_id)->count();
80 80
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 'institution_id' => $admissionInfo['instituion']->id,
127 127
                 'student_status_id' => 1
128 128
             ]);
129
-        } catch (\Throwable $th) {
129
+        }catch (\Throwable $th) {
130 130
             Log::error($th);
131 131
         }
132 132
     }
Please login to merge, or discard this patch.
app/Models/Examination_student.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@
 block discarded – undo
52 52
         $value = self::where('st_no', $data['st_no'])->get();
53 53
         if (count($value) > 0) {
54 54
             self::where('st_no', $data['st_no'])->update($data);
55
-        } else {
55
+        }else {
56 56
             self::insert($data);
57 57
         }
58
-        $output->writeln('Student name: ' . ($data['f_name']) . ' has been inserted to the database');
58
+        $output->writeln('Student name: '.($data['f_name']).' has been inserted to the database');
59 59
     }
60 60
 }
Please login to merge, or discard this patch.
app/Http/Middleware/classTeacher.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
      */
16 16
     public function handle($request, Closure $next)
17 17
     {
18
-        if($request->user()->super_admin == 1){
18
+        if ($request->user()->super_admin == 1) {
19 19
             return $next($request);
20
-        }elseif ($request->user() && (!($request->user()->permissions->isEmpty()))  && $request->user()->permissions[0]->roles &&  $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') {
20
+        }elseif ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') {
21 21
             return $next($request);
22
-        }elseif($request->user() && (!($request->user()->principal->isEmpty()))  && $request->user()->principal[0]->roles &&  $request->user()->principal[0]->roles->code === 'PRINCIPAL'){
22
+        }elseif ($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL') {
23 23
             return $next($request);
24
-        }elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty()))  && $request->user()->zonal_cordinator[0]->roles &&  $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){
24
+        }elseif ($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL') {
25 25
             return $next($request);
26 26
         }
27 27
         return redirect('/login')->with('status', 'Your dont have access for upload data. Please get assign your to the class and try');
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
     {
18 18
         if($request->user()->super_admin == 1){
19 19
             return $next($request);
20
-        }elseif ($request->user() && (!($request->user()->permissions->isEmpty()))  && $request->user()->permissions[0]->roles &&  $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') {
20
+        } elseif ($request->user() && (!($request->user()->permissions->isEmpty()))  && $request->user()->permissions[0]->roles &&  $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') {
21 21
             return $next($request);
22
-        }elseif($request->user() && (!($request->user()->principal->isEmpty()))  && $request->user()->principal[0]->roles &&  $request->user()->principal[0]->roles->code === 'PRINCIPAL'){
22
+        } elseif($request->user() && (!($request->user()->principal->isEmpty()))  && $request->user()->principal[0]->roles &&  $request->user()->principal[0]->roles->code === 'PRINCIPAL'){
23 23
             return $next($request);
24
-        }elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty()))  && $request->user()->zonal_cordinator[0]->roles &&  $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){
24
+        } elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty()))  && $request->user()->zonal_cordinator[0]->roles &&  $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){
25 25
             return $next($request);
26 26
         }
27 27
         return redirect('/login')->with('status', 'Your dont have access for upload data. Please get assign your to the class and try');
Please login to merge, or discard this patch.
app/Http/Controllers/ImportExport.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 
30 30
     }
31 31
 
32
-     /**
33
-    * @return \Illuminate\Support\Collection
34
-    */
32
+        /**
33
+         * @return \Illuminate\Support\Collection
34
+         */
35 35
     public function importExportView()
36 36
     {
37 37
         if(Auth::user()->super_admin ){
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 
46 46
    
47 47
     /**
48
-    * @return \Illuminate\Support\Collection
49
-    */
48
+     * @return \Illuminate\Support\Collection
49
+     */
50 50
     public function export(Request $request) 
51 51
     {
52
-         $request->validate([
52
+            $request->validate([
53 53
                 'class' => 'required'
54 54
             ]);
55 55
         return Excel::download(new UsersExport($request->input('class')), 'users.xlsx');
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 
59 59
 
60 60
     /**
61
-    * @return \Illuminate\Support\Collection
62
-    */
61
+     * @return \Illuminate\Support\Collection
62
+     */
63 63
     public function import(Request $request)
64 64
     {
65 65
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
     */
35 35
     public function importExportView()
36 36
     {
37
-        if(Auth::user()->super_admin ){
37
+        if (Auth::user()->super_admin) {
38 38
             return view('uploadcsv');
39
-        }else{
40
-            $classes = (!Auth::user()->permissions->isEmpty())  ?  Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes;
41
-            return view('importExport')->with('classes',$classes);
39
+        }else {
40
+            $classes = (!Auth::user()->permissions->isEmpty()) ?  Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes;
41
+            return view('importExport')->with('classes', $classes);
42 42
         }
43 43
     }
44 44
 
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 
74 74
 
75 75
             $import = new UsersImport();
76
-            try{
76
+            try {
77 77
                 $files = Storage::disk('sis-bulk-data-files')->allFiles();
78
-                Excel::import($import,request()->file('import_file'));
78
+                Excel::import($import, request()->file('import_file'));
79 79
             }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
80 80
                 $failures = $e->failures();
81 81
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         if(Auth::user()->super_admin ){
38 38
             return view('uploadcsv');
39
-        }else{
39
+        } else{
40 40
             $classes = (!Auth::user()->permissions->isEmpty())  ?  Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes;
41 41
             return view('importExport')->with('classes',$classes);
42 42
         }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             try{
77 77
                 $files = Storage::disk('sis-bulk-data-files')->allFiles();
78 78
                 Excel::import($import,request()->file('import_file'));
79
-            }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
79
+            } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
80 80
                 $failures = $e->failures();
81 81
 
82 82
                 foreach ($failures as $failure) {
Please login to merge, or discard this patch.
app/Models/Institution_student.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public static function boot()
64 64
     {
65 65
         parent::boot();
66
-        self::creating(function ($model) {
66
+        self::creating(function($model) {
67 67
             $model->id = (string) Uuid::generate(4);
68 68
             $model->created = now();
69 69
         });
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public static function createExaminationData($student, $admissionInfo)
134 134
     {
135
-        $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ?  $student['sp_center'] : 0;
135
+        $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0;
136 136
         try {
137 137
             self::create([
138 138
                 'id' => (string) Uuid::generate(4),
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 'created' => now(),
157 157
                 'created_user_id' => 1
158 158
             ]);
159
-        } catch (\Throwable $th) {
159
+        }catch (\Throwable $th) {
160 160
             Log::error($th);
161 161
         }
162 162
     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public static function updateExaminationData($student, $admissionInfo)
172 172
     {
173
-        $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ?  $student['sp_center'] : 0;
173
+        $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0;
174 174
         try {
175 175
             self::where([
176 176
                 'student_id' => $student['student_id'],
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                     'modified_user_id' => 1
192 192
                 ]
193 193
             );
194
-        } catch (\Throwable $th) {
194
+        }catch (\Throwable $th) {
195 195
             Log::error($th);
196 196
         }
197 197
     }
Please login to merge, or discard this patch.
app/Providers/ValidatorExtended.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
             if (empty($value)) {
71 71
                 return false;
72 72
             } elseif ($gradeEntity !== null) {
73
-                $admissionAge = (($gradeEntity->admission_age) * 12) - 1;
73
+                $admissionAge = (($gradeEntity->admission_age)*12) - 1;
74 74
                 $to = $academicPeriod->start_date;
75 75
                 $diff_in_months = $to->diffInMonths($value);
76 76
                 $ageOfStudent = $diff_in_months;
77 77
                 $enrolmentMaximumAge = $admissionAge + 120;
78 78
                 return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge);
79
-            } else {
79
+            }else {
80 80
                 return false;
81 81
             }
82
-        } else {
83
-            $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found';
82
+        }else {
83
+            $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found';
84 84
             $this->_set_custom_stuff();
85 85
             return false;
86 86
         }
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 
92 92
         if (is_numeric($value)) {
93 93
             if ($value < 10) {
94
-                $this->_custom_messages['bmi'] =  $attribute . ' is must greater than 10';
94
+                $this->_custom_messages['bmi'] = $attribute.' is must greater than 10';
95 95
                 $this->_set_custom_stuff();
96 96
                 return false;
97 97
             } elseif ($value > 250) {
98
-                $this->_custom_messages['bmi'] =  $attribute . ' is must smaller than 250';
98
+                $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250';
99 99
                 $this->_set_custom_stuff();
100 100
                 return false;
101 101
             }
102
-        } else {
103
-            $this->_custom_messages['bmi'] =  $attribute . ' is must a valid numeric';
102
+        }else {
103
+            $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric';
104 104
             $this->_set_custom_stuff();
105 105
             return false;
106 106
         }
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
 
110 110
     protected function validateBmi($attribute, $value, $parameters)
111 111
     {
112
-        $bmiGrades =  ['G1', 'G4', 'G7', 'G10'];
112
+        $bmiGrades = ['G1', 'G4', 'G7', 'G10'];
113 113
         $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0])
114 114
             ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id')
115 115
             ->first();
116
-        $educationGrade =  Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first();
116
+        $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first();
117 117
         if (in_array($institutionGrade->code, $bmiGrades)) {
118 118
             if (!empty($value)) {
119 119
                 if (($attribute == 'bmi_height') || ('bmi_weight')) {
120 120
                     return $this->validateHW($attribute, $value);
121 121
                 }
122
-            } else {
123
-                $this->_custom_messages['bmi'] =  $attribute . ' is required for ' . $educationGrade->name;
122
+            }else {
123
+                $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name;
124 124
                 $this->_set_custom_stuff();
125 125
                 return false;
126 126
             }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             if (($attribute == 'bmi_height') || ('bmi_weight')) {
129 129
                 return $this->validateHW($attribute, $value);
130 130
             }
131
-        } else {
131
+        }else {
132 132
             return true;
133 133
         }
134 134
     }
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
     {
138 138
         foreach ($validator->getData() as $data) {
139 139
             if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) {
140
-                $BirthDivision = Area_administrative::where('name', '=',  '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); //
140
+                $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); //
141 141
                 if ($BirthDivision->count() > 0) {
142
-                    $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate']
142
+                    $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate']
143 143
                         ->where('parent_id', '=', $BirthDivision->first()->id)->count();
144
-                    return $BirthArea  > 0;
144
+                    return $BirthArea > 0;
145 145
                 } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) {
146 146
                     $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC';
147 147
                     $this->_set_custom_stuff();
148 148
                     return false;
149
-                } else {
149
+                }else {
150 150
                     return true;
151 151
                 }
152
-            } else {
152
+            }else {
153 153
                 return true;
154 154
             }
155 155
         }
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 
158 158
     protected function validateIsStudentInClass($attribute, $value, $perameters, $validator)
159 159
     {
160
-        $student =  Security_user::where('openemis_no', '=', $value);
160
+        $student = Security_user::where('openemis_no', '=', $value);
161 161
         if ($student->count() > 0) {
162 162
             $student = $student->first()->toArray();
163
-            $check =  Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count();
163
+            $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count();
164 164
             if ($check == 1) {
165 165
                 return true;
166
-            } else {
166
+            }else {
167 167
                 return false;
168 168
             }
169
-        } else {
169
+        }else {
170 170
             return false;
171 171
         }
172 172
     }
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value);
176 176
         if (!$valid) {
177
-            $this->_custom_messages['nic'] = $attribute . ' is not valid,  Please check the NIC number';
177
+            $this->_custom_messages['nic'] = $attribute.' is not valid,  Please check the NIC number';
178 178
             $this->_set_custom_stuff();
179 179
             return false;
180
-        } else {
180
+        }else {
181 181
             return true;
182 182
         }
183 183
     }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     protected function validateUserUnique($attribute, $value, $perameters, $validator)
186 186
     {
187 187
         foreach ($validator->getData() as $data) {
188
-            $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
188
+            $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
189 189
             if ($identityType !== null && ($value !== null)) {
190 190
                 if ($identityType->national_code === 'BC') {
191 191
                     return $this->checkUnique($value, $data, $identityType);
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
     protected function validateIsBc($attribute, $value, $perameters, $validator)
202 202
     {
203 203
         foreach ($validator->getData() as $data) {
204
-            $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
204
+            $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
205 205
             if (($identityType !== null) && ($identityType !== "")) {
206 206
                 if (($identityType->national_code) === 'BC') {
207 207
                     return (strlen((string) $data['identity_number']) < 7);
208
-                } else {
208
+                }else {
209 209
                     return true;
210 210
                 }
211
-            } else {
211
+            }else {
212 212
                 return true;
213 213
             }
214 214
         }
@@ -218,24 +218,24 @@  discard block
 block discarded – undo
218 218
     {
219 219
         $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id);
220 220
         if ($isUnique->count() > 0) {
221
-            $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no;
221
+            $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no;
222 222
             $this->_set_custom_stuff();
223 223
             return false;
224
-        } else {
224
+        }else {
225 225
             return true;
226 226
         }
227 227
     }
228 228
 
229 229
     protected function IsBc($data, $value)
230 230
     {
231
-        $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
231
+        $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
232 232
         if ($identityType !== null) {
233 233
             if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) {
234 234
                 return false;
235
-            } else {
235
+            }else {
236 236
                 return true;
237 237
             }
238
-        } else {
238
+        }else {
239 239
             return true;
240 240
         }
241 241
     }
Please login to merge, or discard this patch.
app/Http/Controllers/FileController.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @param Request $request
34 34
      * @return \Illuminate\Http\JsonResponse
35 35
      */
36
-    public function upload(Request $request){
36
+    public function upload(Request $request) {
37 37
 
38 38
 
39 39
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $institution = auth()->user()->permissions->isEmpty() ? auth()->user()->principal[0]->institution_group[0]->institution->code : auth()->user()->permissions[0]->institution_staff->institution->code;
76 76
 
77 77
 
78
-        $fileName = time().'_'.$institution.'_'.str_replace(' ','_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx';
78
+        $fileName = time().'_'.$institution.'_'.str_replace(' ', '_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx';
79 79
         Storage::disk('local')->putFileAs(
80 80
             'sis-bulk-data-files/',
81 81
             $uploadFile,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         );
84 84
 
85 85
         $upload = new Upload;
86
-        $upload->fileName =$fileName;
86
+        $upload->fileName = $fileName;
87 87
         $upload->model = 'Student';
88 88
         $upload->node = 'None';
89 89
         $upload->institution_class_id = $class->id;
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
         return redirect('/')->withSuccess('The file is uploaded, we will process and let you know by your email');
95 95
     }
96 96
 
97
-    public function updateQueueWithUnprocessedFiles($id, $action){
98
-        if($action == 100){
97
+    public function updateQueueWithUnprocessedFiles($id, $action) {
98
+        if ($action == 100) {
99 99
             DB::table('uploads')
100 100
                 ->where('id', $id)
101 101
                 ->update(['is_processed' => 0]);
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
     }
108 108
 
109 109
 
110
-    public function downloadTemplate(){
110
+    public function downloadTemplate() {
111 111
         $filename = 'censusNo_className_sis_students_bulk_upload';
112 112
         $version = '2007_V2.0_20200610.xlsx';
113
-        $file_path = storage_path() .'/app/public/'. $filename.'_'.$version;;
113
+        $file_path = storage_path().'/app/public/'.$filename.'_'.$version; ;
114 114
         if (file_exists($file_path))
115 115
         {
116 116
             return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [
117
-                'Content-Length: '. filesize($file_path)
117
+                'Content-Length: '.filesize($file_path)
118 118
             ]);
119 119
         }
120 120
         else
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
      * @param $filename
129 129
      * @return Processed excel file with error
130 130
      */
131
-    public function downloadErrorFile($filename){
131
+    public function downloadErrorFile($filename) {
132 132
 
133
-        $file_path = storage_path().'/app/sis-bulk-data-files/processed/'. $filename;
133
+        $file_path = storage_path().'/app/sis-bulk-data-files/processed/'.$filename;
134 134
         if (file_exists($file_path))
135 135
         {
136 136
             return Response::download($file_path, $filename, [
137
-                'Content-Length: '. filesize($file_path)
137
+                'Content-Length: '.filesize($file_path)
138 138
             ]);
139 139
         }
140 140
         else
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
     }
145 145
 
146 146
 
147
-    public function downloadFile($filename){
148
-        $file_path = storage_path().'/app/sis-bulk-data-files/'. $filename;
147
+    public function downloadFile($filename) {
148
+        $file_path = storage_path().'/app/sis-bulk-data-files/'.$filename;
149 149
         if (file_exists($file_path))
150 150
         {
151 151
             return Response::download($file_path, $filename, [
152
-                'Content-Length: '. filesize($file_path)
152
+                'Content-Length: '.filesize($file_path)
153 153
             ]);
154 154
         }
155 155
         else
Please login to merge, or discard this patch.
Braces   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             DB::table('uploads')
100 100
                 ->where('id', $id)
101 101
                 ->update(['is_processed' => 0]);
102
-        }elseif ($action == 200) {
102
+        } elseif ($action == 200) {
103 103
             DB::table('uploads')
104 104
                 ->where('id', $id)
105 105
                 ->update(['is_processed' => 4]);
@@ -116,8 +116,7 @@  discard block
 block discarded – undo
116 116
             return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [
117 117
                 'Content-Length: '. filesize($file_path)
118 118
             ]);
119
-        }
120
-        else
119
+        } else
121 120
         {
122 121
             return response()->view('errors.404');
123 122
         }
@@ -136,8 +135,7 @@  discard block
 block discarded – undo
136 135
             return Response::download($file_path, $filename, [
137 136
                 'Content-Length: '. filesize($file_path)
138 137
             ]);
139
-        }
140
-        else
138
+        } else
141 139
         {
142 140
             abort(404, 'We did not found an error file.');
143 141
         }
@@ -151,8 +149,7 @@  discard block
 block discarded – undo
151 149
             return Response::download($file_path, $filename, [
152 150
                 'Content-Length: '. filesize($file_path)
153 151
             ]);
154
-        }
155
-        else
152
+        } else
156 153
         {
157 154
 
158 155
             abort(404, 'We did not found an error file.');
Please login to merge, or discard this patch.
app/Http/Controllers/CloneController.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 class CloneController extends Controller
18 18
 {
19
-  /**
19
+    /**
20 20
      * Create a new command instance.
21 21
      *
22 22
      * @return void
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
         $this->output->writeln('cleaned subjects');
55 55
 
56 56
         do{
57
-          $deleted =  $this->institution_subjects->where('academic_period_id',$academicPeriod->id)->limit(100000)->delete();
58
-          $this->output->writeln('100000 institutions cleaned shifts');
57
+            $deleted =  $this->institution_subjects->where('academic_period_id',$academicPeriod->id)->limit(100000)->delete();
58
+            $this->output->writeln('100000 institutions cleaned shifts');
59 59
         }while($deleted > 0);
60 60
     }
61 61
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 
87 87
                 }catch (\Exception $e){
88 88
                     dd($e);
89
-                     Log::error($e->getMessage(),[$e]);
89
+                        Log::error($e->getMessage(),[$e]);
90 90
                 }
91 91
             }
92 92
 //            DB::commit();
93 93
         }catch (\Exception $e){
94 94
 //            DB::rollBack();
95
-             Log::error($e->getMessage(),[$e]);
95
+                Log::error($e->getMessage(),[$e]);
96 96
         }
97 97
     }
98 98
 
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
      * @param $academicPeriod
104 104
      */
105 105
     public function insertInstitutionSubjects($subjects, $count,$academicPeriod){
106
-       try{
107
-           $subjects['academic_period_id'] = $academicPeriod->id;
108
-           $subjects['created'] = now();
109
-           unset($subjects['total_male_students']);
110
-           unset($subjects['total_female_students']);
111
-           unset($subjects['id']);
112
-           $this->institution_subjects->create($subjects);
113
-       }catch (\Exception $e){
106
+        try{
107
+            $subjects['academic_period_id'] = $academicPeriod->id;
108
+            $subjects['created'] = now();
109
+            unset($subjects['total_male_students']);
110
+            unset($subjects['total_female_students']);
111
+            unset($subjects['id']);
112
+            $this->institution_subjects->create($subjects);
113
+        }catch (\Exception $e){
114 114
             Log::error($e->getMessage(),[$e]);
115
-       }
115
+        }
116 116
     }
117 117
 
118 118
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                 $this->insertInstitutionClassSubjects($institutionSubjects,$class);
155 155
 //                array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params);
156 156
             }catch (\Exception $e){
157
-                 Log::error($e->getMessage(),[$e]);
157
+                    Log::error($e->getMessage(),[$e]);
158 158
             }
159 159
     }
160 160
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 array_walk($subjects,array($this,'insertClassSubjects'),$class);
165 165
                 $this->output->writeln('updating subjects '. $class->name);
166 166
             }catch (\Exception $e){
167
-                 Log::error($e->getMessage(),[$e]);
167
+                    Log::error($e->getMessage(),[$e]);
168 168
             }
169 169
         };
170 170
     }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                 $this->institution_class_subjects->create($subjectobj);
184 184
             }
185 185
         }catch (\Exception $e){
186
-             Log::error($e->getMessage(),[$e]);
186
+                Log::error($e->getMessage(),[$e]);
187 187
         }
188 188
     }
189 189
 
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 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,31 +46,31 @@  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){
62
+    public function process($shift, $count, $params) {
63 63
         $year = $params['year'];
64 64
         $academicPeriod = $params['academic_period'];
65 65
         $previousAcademicPeriod = $params['previous_academic_period'];
66
-        try{
66
+        try {
67 67
             $shiftId = $this->updateShifts($year, $shift);
68 68
             $institutionClasses = $this->institution_classes->getShiftClasses($shift['id']);
69
-            $institutionSubjects = $this->institution_subjects->getInstitutionSubjects($shift['institution_id'],$previousAcademicPeriod->id);
70
-            array_walk($institutionSubjects , array($this,'insertInstitutionSubjects'),$academicPeriod);
71
-            if (!empty($institutionClasses) && !is_null($shiftId) && !is_null($academicPeriod) ) {
69
+            $institutionSubjects = $this->institution_subjects->getInstitutionSubjects($shift['institution_id'], $previousAcademicPeriod->id);
70
+            array_walk($institutionSubjects, array($this, 'insertInstitutionSubjects'), $academicPeriod);
71
+            if (!empty($institutionClasses) && !is_null($shiftId) && !is_null($academicPeriod)) {
72 72
 
73
-                $newInstitutionClasses = $this->generateNewClass($institutionClasses,$shiftId,$academicPeriod->id);
73
+                $newInstitutionClasses = $this->generateNewClass($institutionClasses, $shiftId, $academicPeriod->id);
74 74
 
75 75
                 $params = [
76 76
                     'previous_academic_period_id' => $previousAcademicPeriod->id,
@@ -78,21 +78,21 @@  discard block
 block discarded – undo
78 78
                     'shift_id' =>$shiftId
79 79
                 ];
80 80
 
81
-                try{
82
-                    array_walk($newInstitutionClasses,array($this,'insertInstitutionClasses'),$params);
81
+                try {
82
+                    array_walk($newInstitutionClasses, array($this, 'insertInstitutionClasses'), $params);
83 83
                     $newInstitutionClasses = $this->institution_classes->getShiftClasses($shiftId);
84 84
                     $this->output->writeln('##########################################################################################################################');
85
-                    $this->output->writeln('updating from '. $shiftId);
85
+                    $this->output->writeln('updating from '.$shiftId);
86 86
 
87
-                }catch (\Exception $e){
87
+                }catch (\Exception $e) {
88 88
                     dd($e);
89
-                     Log::error($e->getMessage(),[$e]);
89
+                     Log::error($e->getMessage(), [$e]);
90 90
                 }
91 91
             }
92 92
 //            DB::commit();
93
-        }catch (\Exception $e){
93
+        }catch (\Exception $e) {
94 94
 //            DB::rollBack();
95
-             Log::error($e->getMessage(),[$e]);
95
+             Log::error($e->getMessage(), [$e]);
96 96
         }
97 97
     }
98 98
 
@@ -102,31 +102,31 @@  discard block
 block discarded – undo
102 102
      * @param $count
103 103
      * @param $academicPeriod
104 104
      */
105
-    public function insertInstitutionSubjects($subjects, $count,$academicPeriod){
106
-       try{
105
+    public function insertInstitutionSubjects($subjects, $count, $academicPeriod) {
106
+       try {
107 107
            $subjects['academic_period_id'] = $academicPeriod->id;
108 108
            $subjects['created'] = now();
109 109
            unset($subjects['total_male_students']);
110 110
            unset($subjects['total_female_students']);
111 111
            unset($subjects['id']);
112 112
            $this->institution_subjects->create($subjects);
113
-       }catch (\Exception $e){
114
-            Log::error($e->getMessage(),[$e]);
113
+       }catch (\Exception $e) {
114
+            Log::error($e->getMessage(), [$e]);
115 115
        }
116 116
     }
117 117
 
118 118
 
119
-    public function  insertInstitutionClasses($class,$count,$param){
120
-            try{
119
+    public function  insertInstitutionClasses($class, $count, $param) {
120
+            try {
121 121
 
122 122
                 $academicPeriod = $param['academic_period_id'];
123 123
                 $educationGrdae = $class['education_grade_id'];
124 124
 
125 125
                 $classId = $class['id'];
126 126
                 unset($class['id']);
127
-                $institutionSubjects = Institution_subject::query()->where('education_grade_id',$class['education_grade_id'])
128
-                    ->where('institution_id',$class['institution_id'])
129
-                    ->where('academic_period_id',$academicPeriod)->get()->toArray();
127
+                $institutionSubjects = Institution_subject::query()->where('education_grade_id', $class['education_grade_id'])
128
+                    ->where('institution_id', $class['institution_id'])
129
+                    ->where('academic_period_id', $academicPeriod)->get()->toArray();
130 130
                 $params = [
131 131
                     'class'=>$class,
132 132
                     'subjects'=>$institutionSubjects,
@@ -139,39 +139,39 @@  discard block
 block discarded – undo
139 139
                 $class['no_of_students'] = $noOfStudents;
140 140
                 $class['created'] = now();
141 141
                 $class['institution_shift_id'] = $param['shift_id'];
142
-                $this->output->writeln('Create class:'. $class['name']);
142
+                $this->output->writeln('Create class:'.$class['name']);
143 143
                 $class = Institution_class::create($class);
144 144
                 $institutionClassGrdaeObj['institution_class_id'] = $class->id;
145 145
                 $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae;
146 146
                 Institution_class_grade::create($institutionClassGrdaeObj);
147
-                $institutionSubjects = Institution_subject::query()->where('education_grade_id',$educationGrdae)
148
-                    ->where('institution_id',$class->institution_id)
149
-                    ->where('academic_period_id',$academicPeriod)
147
+                $institutionSubjects = Institution_subject::query()->where('education_grade_id', $educationGrdae)
148
+                    ->where('institution_id', $class->institution_id)
149
+                    ->where('academic_period_id', $academicPeriod)
150 150
                     ->groupBy('education_subject_id')
151 151
                     ->get()
152 152
                     ->toArray();
153 153
                 $params['class'] = $class;
154
-                $this->insertInstitutionClassSubjects($institutionSubjects,$class);
154
+                $this->insertInstitutionClassSubjects($institutionSubjects, $class);
155 155
 //                array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params);
156
-            }catch (\Exception $e){
157
-                 Log::error($e->getMessage(),[$e]);
156
+            }catch (\Exception $e) {
157
+                 Log::error($e->getMessage(), [$e]);
158 158
             }
159 159
     }
160 160
 
161
-    public function insertInstitutionClassSubjects($subjects,$class){
162
-        if(!empty($subjects)){
163
-            try{
164
-                array_walk($subjects,array($this,'insertClassSubjects'),$class);
165
-                $this->output->writeln('updating subjects '. $class->name);
166
-            }catch (\Exception $e){
167
-                 Log::error($e->getMessage(),[$e]);
161
+    public function insertInstitutionClassSubjects($subjects, $class) {
162
+        if (!empty($subjects)) {
163
+            try {
164
+                array_walk($subjects, array($this, 'insertClassSubjects'), $class);
165
+                $this->output->writeln('updating subjects '.$class->name);
166
+            }catch (\Exception $e) {
167
+                 Log::error($e->getMessage(), [$e]);
168 168
             }
169 169
         };
170 170
     }
171 171
 
172 172
   
173
-    public function insertClassSubjects($subject,$count,$newClassId){
174
-        try{
173
+    public function insertClassSubjects($subject, $count, $newClassId) {
174
+        try {
175 175
             $subjectobj['status'] = 1;
176 176
             $subjectobj['created_user_id'] = 1;
177 177
             $subjectobj['created'] = now();
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
             $subjectobj['institution_class_id'] = $newClassId->id;
180 180
             $subjectobj['institution_subject_id'] = $subject['id'];
181 181
 
182
-            if(!$this->institution_class_subjects->isDuplicated($subjectobj)){
182
+            if (!$this->institution_class_subjects->isDuplicated($subjectobj)) {
183 183
                 $this->institution_class_subjects->create($subjectobj);
184 184
             }
185
-        }catch (\Exception $e){
186
-             Log::error($e->getMessage(),[$e]);
185
+        }catch (\Exception $e) {
186
+             Log::error($e->getMessage(), [$e]);
187 187
         }
188 188
     }
189 189
 
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
      * @param $academicPeriod
196 196
      * @return array
197 197
      */
198
-    public function generateNewClass($classes,$shiftId,$academicPeriod){
198
+    public function generateNewClass($classes, $shiftId, $academicPeriod) {
199 199
         $newClasses = [];
200
-        foreach ( $classes as $class) {
200
+        foreach ($classes as $class) {
201 201
             $noOfStudents = $class['no_of_students'] == 0 ? 40 : $class['no_of_students'];
202 202
             $class['academic_period_id'] = $academicPeriod;
203 203
             $class['no_of_students'] = $noOfStudents;
204 204
             $class['created'] = now();
205 205
             $class['institution_shift_id'] = $shiftId;
206
-            array_push($newClasses,$class);
206
+            array_push($newClasses, $class);
207 207
         }
208 208
         return $newClasses;
209 209
     }
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
      * @param $shift
215 215
      * @return mixed
216 216
      */
217
-    public function updateShifts($year,$shift){
217
+    public function updateShifts($year, $shift) {
218 218
         $academicPeriod = $this->academic_period->getAcademicPeriod($year);
219
-        $this->shifts->where('id',$shift['id'])->update(['cloned' => $year]);
219
+        $this->shifts->where('id', $shift['id'])->update(['cloned' => $year]);
220 220
         $shift['academic_period_id'] = $academicPeriod->id;
221 221
         $exist = $this->shifts->shiftExists($shift);
222
-        return $this->shifts->create((array)$shift)->id;
222
+        return $this->shifts->create((array) $shift)->id;
223 223
     }
224 224
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
                     $this->output->writeln('##########################################################################################################################');
85 85
                     $this->output->writeln('updating from '. $shiftId);
86 86
 
87
-                }catch (\Exception $e){
87
+                } catch (\Exception $e){
88 88
                     dd($e);
89 89
                      Log::error($e->getMessage(),[$e]);
90 90
                 }
91 91
             }
92 92
 //            DB::commit();
93
-        }catch (\Exception $e){
93
+        } catch (\Exception $e){
94 94
 //            DB::rollBack();
95 95
              Log::error($e->getMessage(),[$e]);
96 96
         }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
            unset($subjects['total_female_students']);
111 111
            unset($subjects['id']);
112 112
            $this->institution_subjects->create($subjects);
113
-       }catch (\Exception $e){
113
+       } catch (\Exception $e){
114 114
             Log::error($e->getMessage(),[$e]);
115 115
        }
116 116
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 $params['class'] = $class;
154 154
                 $this->insertInstitutionClassSubjects($institutionSubjects,$class);
155 155
 //                array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params);
156
-            }catch (\Exception $e){
156
+            } catch (\Exception $e){
157 157
                  Log::error($e->getMessage(),[$e]);
158 158
             }
159 159
     }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             try{
164 164
                 array_walk($subjects,array($this,'insertClassSubjects'),$class);
165 165
                 $this->output->writeln('updating subjects '. $class->name);
166
-            }catch (\Exception $e){
166
+            } catch (\Exception $e){
167 167
                  Log::error($e->getMessage(),[$e]);
168 168
             }
169 169
         };
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             if(!$this->institution_class_subjects->isDuplicated($subjectobj)){
183 183
                 $this->institution_class_subjects->create($subjectobj);
184 184
             }
185
-        }catch (\Exception $e){
185
+        } catch (\Exception $e){
186 186
              Log::error($e->getMessage(),[$e]);
187 187
         }
188 188
     }
Please login to merge, or discard this patch.