Test Setup Failed
Pull Request — master (#461)
by Mohamed
07:26
created
app/Console/Commands/cleanClone.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -53,32 +53,32 @@
 block discarded – undo
53 53
         $this->start_time = microtime(TRUE);
54 54
         $year = $this->argument('year');
55 55
         $academicPeriod = $this->academic_period->getAcademicPeriod($year);
56
-        if($year <= 2019) {
56
+        if ($year <= 2019) {
57 57
             $this->output->writeln('2019 or previous data not allowed to delete from this script');
58 58
             exit();
59 59
         }
60
-        $shift = $this->shifts->getShiftsToDelete($year,$academicPeriod->id);
61
-        array_walk($shift,array($this,'process'));
60
+        $shift = $this->shifts->getShiftsToDelete($year, $academicPeriod->id);
61
+        array_walk($shift, array($this, 'process'));
62 62
 
63
-        $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete');
63
+        $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete');
64 64
         $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$');
65 65
  
66 66
        
67 67
     }
68 68
 
69
-    public function process($shift){
69
+    public function process($shift) {
70 70
        
71 71
     try {
72
-        $institutionClasses = $this->institution_classes->select('id')->where('id',$shift['id']);
73
-        $this->institution_classes->where('id',$shift['id'])->delete();
72
+        $institutionClasses = $this->institution_classes->select('id')->where('id', $shift['id']);
73
+        $this->institution_classes->where('id', $shift['id'])->delete();
74 74
  
75
-        $this->institution_class_subjects->whereIn('id',$institutionClasses)->delete();
75
+        $this->institution_class_subjects->whereIn('id', $institutionClasses)->delete();
76 76
  
77
-        $this->shifts->where('id',$shift['id'])->delete();
77
+        $this->shifts->where('id', $shift['id'])->delete();
78 78
  
79
-        $this->output->writeln('Deleted '. $shift['id'] . ($this->end_time - $this->start_time) . ' seconds to complete');
79
+        $this->output->writeln('Deleted '.$shift['id'].($this->end_time - $this->start_time).' seconds to complete');
80 80
  
81
-    } catch (\Throwable $th) {
81
+    }catch (\Throwable $th) {
82 82
         dd($th);
83 83
     }
84 84
       
Please login to merge, or discard this patch.
app/Console/Commands/UpdateStudentsCount.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
      */
28 28
     protected $description = 'Update the students count male/female';
29 29
 
30
-      /**
31
-     * Create a new command instance.
32
-     *
33
-     * @return void
34
-     */
30
+        /**
31
+         * Create a new command instance.
32
+         *
33
+         * @return void
34
+         */
35 35
     public function __construct()
36 36
     {
37 37
         parent::__construct();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,16 +46,16 @@
 block discarded – undo
46 46
     public function handle()
47 47
     {
48 48
         $classes = Institution_class::get()->toArray();
49
-        $this->output->writeln('start updating:'. count($classes));
49
+        $this->output->writeln('start updating:'.count($classes));
50 50
         $this->output->writeln('#########################################');
51
-        array_walk($classes , array($this,'updateCount'));
52
-        $this->output->writeln('start finish:'. count($classes));
51
+        array_walk($classes, array($this, 'updateCount'));
52
+        $this->output->writeln('start finish:'.count($classes));
53 53
         $this->output->writeln('#########################################');
54 54
     }
55 55
 
56
-    public function updateCount($class){
57
-        $this->output->writeln('updating:'. $class['id']);
58
-        $totalStudents =  Institution_class_student::getStudentsCount($class['id']);
56
+    public function updateCount($class) {
57
+        $this->output->writeln('updating:'.$class['id']);
58
+        $totalStudents = Institution_class_student::getStudentsCount($class['id']);
59 59
         Institution_class::where('id', '=', $class['id'])
60 60
         ->update([
61 61
             'total_male_students' => $totalStudents['total_male_students'],
Please login to merge, or discard this patch.
app/Console/Commands/ImportStudents.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -137,9 +137,9 @@
 block discarded – undo
137 137
             ->join('user_contacts', 'uploads.security_user_id', '=', 'user_contacts.security_user_id')
138 138
             ->join('contact_types', 'user_contacts.contact_type_id', '=', 'contact_types.id')
139 139
             //only for UAT
140
-             ->where('contact_types.contact_option_id', '=', 5)
140
+                ->where('contact_types.contact_option_id', '=', 5)
141 141
 //            ->where('contact_types.contact_option_id', '!=', 5)
142
-             ->where('contact_types.name', '=', 'TestEmail')
142
+                ->where('contact_types.name', '=', 'TestEmail')
143 143
             ->limit(1)
144 144
             ->get()->toArray();
145 145
         $node = $this->argument('node');
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function __construct()
49 49
     {
50
-        $this->output =  new \Symfony\Component\Console\Output\ConsoleOutput();
50
+        $this->output = new \Symfony\Component\Console\Output\ConsoleOutput();
51 51
         parent::__construct();
52 52
     }
53 53
 
@@ -69,18 +69,18 @@  discard block
 block discarded – undo
69 69
                         $this->process($files);
70 70
                         unset($files);
71 71
                         exit();
72
-                    } else {
72
+                    }else {
73 73
                         $output = new \Symfony\Component\Console\Output\ConsoleOutput();
74 74
                         $this->output->writeln('No files found,Waiting for files');
75 75
                         exit();
76 76
                     }
77
-                } catch (Exception $e) {
77
+                }catch (Exception $e) {
78 78
                     $output = new \Symfony\Component\Console\Output\ConsoleOutput();
79 79
                     $this->output->writeln($e);
80 80
                     sleep(300);
81 81
                     $this->handle();
82 82
                 }
83
-            } else {
83
+            }else {
84 84
                 exit();
85 85
             }
86 86
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $files[0]['node'] = $node;
96 96
         $this->processSheet($files[0]);
97 97
         $now = Carbon::now()->tz('Asia/Colombo');
98
-        $this->output->writeln('=============== Time taken to batch ' . $now->diffInMinutes($time));
98
+        $this->output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time));
99 99
     }
100 100
 
101 101
     protected function getTerminatedFiles()
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
     public function processSuccessEmail($file, $user, $subject)
168 168
     {
169 169
         $file['subject'] = $subject;
170
-        $this->output->writeln('Processing the file: ' . $file['filename']);
170
+        $this->output->writeln('Processing the file: '.$file['filename']);
171 171
         try {
172 172
             Mail::to($user->email)->send(new StudentImportSuccess($file));
173 173
             DB::table('uploads')
174 174
                 ->where('id', $file['id'])
175 175
                 ->update(['is_processed' => 1, 'is_email_sent' => 1, 'updated_at' => now()]);
176
-        } catch (\Exception $ex) {
176
+        }catch (\Exception $ex) {
177 177
             $this->output->writeln($ex->getMessage());
178 178
             DB::table('uploads')
179 179
                 ->where('id', $file['id'])
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             DB::table('uploads')
190 190
                 ->where('id', $file['id'])
191 191
                 ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]);
192
-        } catch (\Exception $ex) {
192
+        }catch (\Exception $ex) {
193 193
             $this->output->writeln($ex->getMessage());
194 194
             DB::table('uploads')
195 195
                 ->where('id', $file['id'])
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             DB::table('uploads')
206 206
                 ->where('id', $file['id'])
207 207
                 ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]);
208
-        } catch (\Exception $ex) {
208
+        }catch (\Exception $ex) {
209 209
             $this->output->writeln($ex->getMessage());
210 210
             DB::table('uploads')
211 211
                 ->where('id', $file['id'])
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
         $node = $this->argument('node');
219 219
         if ($node == $file['node']) {
220 220
             $output = new \Symfony\Component\Console\Output\ConsoleOutput();
221
-            $this->output->writeln('Processing from:' . $node);
221
+            $this->output->writeln('Processing from:'.$node);
222 222
             return true;
223
-        } else {
223
+        }else {
224 224
             exit;
225 225
             return false;
226 226
         }
@@ -232,20 +232,20 @@  discard block
 block discarded – undo
232 232
         $user = User::find($file['security_user_id']);
233 233
         $this->checkNode($file);
234 234
         $this->output->writeln('##########################################################################################################################');
235
-        $this->output->writeln('Processing the file: ' . $file['filename']);
235
+        $this->output->writeln('Processing the file: '.$file['filename']);
236 236
         if ($this->checkTime()) {
237 237
             try {
238 238
                 $this->import($file, 1, 'C');
239 239
                 sleep(10);
240 240
                 $this->import($file, 2, 'B');
241
-            } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
241
+            }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
242 242
                 $this->output->writeln($e->getMessage());
243 243
                 try {
244 244
                     Mail::to($user->email)->send(new IncorrectTemplate($file));
245 245
                     DB::table('uploads')
246 246
                         ->where('id', $file['id'])
247 247
                         ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]);
248
-                } catch (\Exception $ex) {
248
+                }catch (\Exception $ex) {
249 249
                     $this->output->writeln($e->getMessage());
250 250
                     $this->handle();
251 251
                     DB::table('uploads')
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
                         ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]);
254 254
                 }
255 255
             }
256
-        } else {
256
+        }else {
257 257
             exit();
258 258
         }
259 259
     }
260 260
 
261 261
     protected function getType($file)
262 262
     {
263
-        $file =  storage_path() . '/app/sis-bulk-data-files/' . $file;
264
-        $inputFileType =  \PhpOffice\PhpSpreadsheet\IOFactory::identify($file);
263
+        $file = storage_path().'/app/sis-bulk-data-files/'.$file;
264
+        $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file);
265 265
         return $inputFileType;
266 266
     }
267 267
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
             ini_set('memory_limit', '2048M');
323 323
             $this->getFileSize($file);
324 324
             $user = User::find($file['security_user_id']);
325
-            $excelFile = '/sis-bulk-data-files/' . $file['filename'];
325
+            $excelFile = '/sis-bulk-data-files/'.$file['filename'];
326 326
             $this->higestRow = $this->getHigestRow($file, $sheet, $column);
327 327
             switch ($sheet) {
328 328
                 case 1;
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
                                 ->update(['insert' => 3, 'updated_at' => now()]);
342 342
                             $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Partial Success ');
343 343
                             $this->stdOut('Insert Students', $this->higestRow);
344
-                        } else {
344
+                        }else {
345 345
                             $this->processSuccessEmail($file, $user, 'Fresh Student Data Upload:Success ');
346 346
                             $this->stdOut('Insert Students', $this->higestRow);
347 347
                         }
348
-                    } else if (($this->getSheetName($file, 'Insert Students')) && $this->higestRow > 0) {
348
+                    }else if (($this->getSheetName($file, 'Insert Students')) && $this->higestRow > 0) {
349 349
                         DB::table('uploads')
350 350
                             ->where('id', $file['id'])
351 351
                             ->update(['is_processed' => 2]);
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
                                 ->update(['update' => 3, 'is_processed' => 1, 'updated_at' => now()]);
368 368
                             $this->processFailedEmail($file, $user, 'Existing Student Data Update:Partial Success ');
369 369
                             $this->stdOut('Update Students', $this->higestRow);
370
-                        } else {
370
+                        }else {
371 371
                             $this->processSuccessEmail($file, $user, 'Existing Student Data Update:Success ');
372 372
                             $this->stdOut('Update Students', $this->higestRow);
373 373
                         }
374
-                    } else if (($this->getSheetName($file, 'Update Students')) && $this->higestRow == 0) {
374
+                    }else if (($this->getSheetName($file, 'Update Students')) && $this->higestRow == 0) {
375 375
                         DB::table('uploads')
376 376
                             ->where('id', $file['id'])
377 377
                             ->update(['is_processed' => 2, 'updated_at' => now()]);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
                     }
380 380
                     break;
381 381
             }
382
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
382
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
383 383
             $this->output->writeln($e->getMessage());
384 384
             if ($sheet == 1) {
385 385
                 self::writeErrors($e, $file, 'Insert Students');
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                     ->where('id', $file['id'])
388 388
                     ->update(['insert' => 2, 'updated_at' => now()]);
389 389
                 $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Failed');
390
-            } else if ($sheet == 2) {
390
+            }else if ($sheet == 2) {
391 391
                 self::writeErrors($e, $file, 'Update Students');
392 392
                 DB::table('uploads')
393 393
                     ->where('id', $file['id'])
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
                 $this->processFailedEmail($file, $user, 'Existing Student Data Update:Failed');
396 396
             }
397 397
             DB::table('uploads')
398
-                ->where('id',  $file['id'])
398
+                ->where('id', $file['id'])
399 399
                 ->update(['is_processed' => 2, 'updated_at' => now()]);
400 400
         }
401 401
     }
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
 
414 414
     protected function  getFileSize($file)
415 415
     {
416
-        $excelFile =  '/sis-bulk-data-files/' . $file['filename'];
416
+        $excelFile = '/sis-bulk-data-files/'.$file['filename'];
417 417
         $size = Storage::disk('local')->size($excelFile);
418 418
         $user = User::find($file['security_user_id']);
419 419
         if ($size > 0) {
420 420
             return true;
421
-        } else {
421
+        }else {
422 422
             DB::table('uploads')
423
-                ->where('id',  $file['id'])
423
+                ->where('id', $file['id'])
424 424
                 ->update(['is_processed' => 2, 'updated_at' => now()]);
425 425
             $this->stdOut('No valid data found :Please re-upload the file', 0);
426 426
             $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file');
@@ -430,21 +430,21 @@  discard block
 block discarded – undo
430 430
     protected function setReader($file)
431 431
     {
432 432
         try {
433
-            $excelFile =  '/sis-bulk-data-files/processed/' . $file['filename'];
433
+            $excelFile = '/sis-bulk-data-files/processed/'.$file['filename'];
434 434
             $exists = Storage::disk('local')->exists($excelFile);
435 435
             if (!$exists) {
436 436
 
437
-                $excelFile =  "/sis-bulk-data-files/" . $file['filename'];
437
+                $excelFile = "/sis-bulk-data-files/".$file['filename'];
438 438
             }
439
-            $excelFile = storage_path() . "/app" . $excelFile;
439
+            $excelFile = storage_path()."/app".$excelFile;
440 440
             $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->getType($file['filename']));
441
-            $objPHPExcel =  $reader->load($excelFile);
441
+            $objPHPExcel = $reader->load($excelFile);
442 442
             return $objPHPExcel;
443
-        } catch (Exception $e) {
443
+        }catch (Exception $e) {
444 444
             $this->output->writeln($e->getMessage());
445 445
             $user = User::find($file['security_user_id']);
446 446
             DB::table('uploads')
447
-                ->where('id',  $file['id'])
447
+                ->where('id', $file['id'])
448 448
                 ->update(['is_processed' => 2, 'updated_at' => now()]);
449 449
             $this->stdOut('No valid data found :Please re-upload the file', 0);
450 450
             $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file');
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
     {
456 456
         try {;
457 457
             $objPHPExcel = $this->setReader($file);
458
-            return $objPHPExcel->getSheetByName($sheet)  !== null;
459
-        } catch (Exception $e) {
458
+            return $objPHPExcel->getSheetByName($sheet) !== null;
459
+        }catch (Exception $e) {
460 460
             $this->output->writeln($e->getMessage());
461 461
             $user = User::find($file['security_user_id']);
462 462
             DB::table('uploads')
463
-                ->where('id',  $file['id'])
463
+                ->where('id', $file['id'])
464 464
                 ->update(['is_processed' => 2, 'updated_at' => now()]);
465 465
             $this->stdOut('No valid data found :Please re-upload the file', 0);
466 466
             $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file');
@@ -473,17 +473,17 @@  discard block
 block discarded – undo
473 473
             $reader = $this->setReader($file);
474 474
             $reader->setActiveSheetIndex($sheet);
475 475
             $higestRow = 0;
476
-            $highestRow =  $reader->getActiveSheet()->getHighestRow($column);
476
+            $highestRow = $reader->getActiveSheet()->getHighestRow($column);
477 477
             for ($row = 3; $row <= $highestRow; $row++) {
478
-                $rowData = $reader->getActiveSheet()->getCell($column . $row)->getValue();
478
+                $rowData = $reader->getActiveSheet()->getCell($column.$row)->getValue();
479 479
                 if (empty($rowData) || $rowData == null) {
480 480
                     continue;
481
-                } else {
481
+                }else {
482 482
                     $higestRow += 1;
483 483
                 }
484 484
             }
485 485
             return $higestRow;
486
-        } catch (\Exception $e) {
486
+        }catch (\Exception $e) {
487 487
             $this->output->writeln($e->getMessage());
488 488
             $user = User::find($file['security_user_id']);
489 489
             DB::beginTransaction();
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 
499 499
     protected function stdOut($title, $rows)
500 500
     {
501
-        $this->output->writeln($title . ' Process completed at . ' . ' ' . now());
501
+        $this->output->writeln($title.' Process completed at . '.' '.now());
502 502
         $now = Carbon::now()->tz('Asia/Colombo');
503
-        $this->output->writeln('Total Processed lines: ' . $rows);
504
-        $this->output->writeln('Time taken to process           : ' .   $now->diffInSeconds($this->startTime) . ' Seconds');
503
+        $this->output->writeln('Total Processed lines: '.$rows);
504
+        $this->output->writeln('Time taken to process           : '.$now->diffInSeconds($this->startTime).' Seconds');
505 505
         $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------');
506 506
     }
507 507
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         $sheet = $reader->getActiveSheet();
514 514
         if (!in_array($row, $params['rows'])) {
515 515
             $output = new \Symfony\Component\Console\Output\ConsoleOutput();
516
-            $this->output->writeln(' removing row . ' . ' ' . $row);
516
+            $this->output->writeln(' removing row . '.' '.$row);
517 517
             $reader->getActiveSheet()->getCellCollection()->removeRow($row);
518 518
         }
519 519
     }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
             if (count($failures) > 0) {
540 540
                 $rows = array_map('rows', $failures);
541 541
                 $rows = array_unique($rows);
542
-                $rowIndex =   range(3, $this->higestRow + 2);
542
+                $rowIndex = range(3, $this->higestRow + 2);
543 543
                 $params = [
544 544
                     'rows' => $rows,
545 545
                     'reader' => $reader
@@ -548,17 +548,17 @@  discard block
 block discarded – undo
548 548
                 array_walk($rowIndex, array($this, 'removeRows'), $params);
549 549
                 $objWriter = $this->getSheetWriter($file, $reader);
550 550
                 Storage::disk('local')->makeDirectory('sis-bulk-data-files/processed');
551
-                $objWriter->save(storage_path() . '/app/sis-bulk-data-files/processed/' . $file['filename']);
551
+                $objWriter->save(storage_path().'/app/sis-bulk-data-files/processed/'.$file['filename']);
552 552
                 $now = Carbon::now()->tz('Asia/Colombo');
553
-                $this->output->writeln($reader->getActiveSheet()->getTitle() . ' Process completed at . ' . ' ' . now());
554
-                $this->output->writeln('memory usage for the processes : ' . (memory_get_usage() - $baseMemory));
555
-                $this->output->writeln('Time taken to process           : ' .   $now->diffInSeconds($this->startTime) . ' Seconds');
556
-                $this->output->writeln(' errors reported               : ' . count($failures));
553
+                $this->output->writeln($reader->getActiveSheet()->getTitle().' Process completed at . '.' '.now());
554
+                $this->output->writeln('memory usage for the processes : '.(memory_get_usage() - $baseMemory));
555
+                $this->output->writeln('Time taken to process           : '.$now->diffInSeconds($this->startTime).' Seconds');
556
+                $this->output->writeln(' errors reported               : '.count($failures));
557 557
                 $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------');
558 558
                 unset($objWriter);
559 559
                 unset($failures);
560 560
             }
561
-        } catch (Eception $e) {
561
+        }catch (Eception $e) {
562 562
             $this->output->writeln($e->getMessage());
563 563
             $user = User::find($file['security_user_id']);
564 564
             DB::beginTransaction();
Please login to merge, or discard this patch.
app/Console/Commands/UpdateViews.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
      */
40 40
     public function handle()
41 41
     {
42
-       $views = new DashboardViewsController();
43
-       $views->callback();
42
+        $views = new DashboardViewsController();
43
+        $views->callback();
44 44
     }
45 45
 }
Please login to merge, or discard this patch.
app/Console/Commands/cleanConfig.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@
 block discarded – undo
52 52
             'academic_period' => $academicPeriod
53 53
         ];
54 54
 
55
-        if($year <= 2019){
55
+        if ($year <= 2019) {
56 56
             die('Academic Year 2019 or earlier can`t be deleted');
57
-        }else{
57
+        }else {
58 58
             $this->clone->cleanConfig($params);
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 
55 55
         if($year <= 2019){
56 56
             die('Academic Year 2019 or earlier can`t be deleted');
57
-        }else{
57
+        } else{
58 58
             $this->clone->cleanConfig($params);
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
app/Models/Security_user.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -152,12 +152,12 @@
 block discarded – undo
152 152
             ->get()->toArray();
153 153
     }
154 154
 
155
-     /**
156
-     * First level search for students
157
-     *
158
-     * @param array $student
159
-     * @return array
160
-     */
155
+        /**
156
+         * First level search for students
157
+         *
158
+         * @param array $student
159
+         * @return array
160
+         */
161 161
     public function getStudentCount($student)
162 162
     {
163 163
         return $this
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
     public function getMatches($student)
145 145
     {
146 146
         return $this
147
-        ->where('gender_id',$student['gender'] + 1)
148
-        ->where('institutions.code',$student['schoolid'])
149
-        ->where('date_of_birth',$student['b_date'])
147
+        ->where('gender_id', $student['gender'] + 1)
148
+        ->where('institutions.code', $student['schoolid'])
149
+        ->where('date_of_birth', $student['b_date'])
150 150
             ->join('institution_students', 'security_users.id', 'institution_students.student_id')
151 151
             ->join('institutions', 'institution_students.institution_id', 'institutions.id')
152 152
             ->get()->toArray();
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
     public function getStudentCount($student)
162 162
     {
163 163
         return $this
164
-        ->where('gender_id',$student['gender'] + 1)
165
-        ->where('institutions.code',$student['schoolid'])
166
-        ->where('date_of_birth',$student['b_date'])
164
+        ->where('gender_id', $student['gender'] + 1)
165
+        ->where('institutions.code', $student['schoolid'])
166
+        ->where('date_of_birth', $student['b_date'])
167 167
             ->join('institution_students', 'security_users.id', 'institution_students.student_id')
168 168
             ->join('institutions', 'institution_students.institution_id', 'institutions.id')
169 169
             ->count();
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             $studentData['id'] = $id;
198 198
             $this->uniqueUserId->updateOrInsertRecord($studentData);
199 199
             return $studentData;
200
-        } catch (\Exception $th) {
200
+        }catch (\Exception $th) {
201 201
             Log::error($th->getMessage());
202 202
             // in case of duplication of the Unique ID this will recursive.
203 203
             $this->insertExaminationStudent($student);
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         $this->uniqueUserId = new Unique_user_id();
218 218
         $this->uniqueUId = new UniqueUid();
219 219
         // regenerate unique id if it's not available
220
-        $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'],9)) ?  $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric();
220
+        $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric();
221 221
 
222 222
         $studentData = [
223 223
             'username' => str_replace('-', '', $uniqueId),
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
         ];
232 232
 
233 233
         try {
234
-            self::where( 'id'  , $sis_student['student_id'])->update($studentData);
234
+            self::where('id', $sis_student['student_id'])->update($studentData);
235 235
             $studentData['id'] = $sis_student['student_id'];
236 236
             $this->uniqueUserId->updateOrInsertRecord($studentData);
237 237
             return $studentData;
238
-        } catch (\Exception $th) {
238
+        }catch (\Exception $th) {
239 239
             Log::error($th);
240 240
             // in case of duplication of the Unique ID this will recursive.
241 241
             $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric();
Please login to merge, or discard this patch.
app/Models/Unique_user_id.php 2 patches
Indentation   +6 added lines, -6 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,10 +69,10 @@  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
-           Log::error($th->getMessage());
76
-       }
72
+        } catch (\Exception $th) {
73
+            $user['openemis_no'] = $this->uniqueUserId::getUniqueAlphanumeric();
74
+            $this->updateOrInsertRecord($user);
75
+            Log::error($th->getMessage());
76
+        }
77 77
     }
78 78
 }
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
            Log::error($th->getMessage());
Please login to merge, or discard this patch.
app/Console/Commands/ExaminationStudentMigrate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
             $output->writeln('###########################################------starting export------###########################################');
48 48
             $this->examinationController->export();
49 49
             $output->writeln('###########################################------Finished inserting file records------###########################################');
50
-        } else {
50
+        }else {
51 51
             $this->examinationController->doMatch($this->argument('offset'), $this->argument('limit'), $this->argument(('mode')));
52 52
             $this->examinationController->export();
53 53
         }
Please login to merge, or discard this patch.
app/Http/Controllers/ExaminationStudentsController.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $this->grade = $grade;
31 31
         $this->student = new Security_user();
32 32
         $this->examination_student = new Examination_student();
33
-        $this->academic_period =  Academic_period::where('code', '=', $this->year)->first();
33
+        $this->academic_period = Academic_period::where('code', '=', $this->year)->first();
34 34
         $this->education_grade = Education_grade::where('code', '=', $this->grade)->first();
35 35
         $this->output = new \Symfony\Component\Console\Output\ConsoleOutput();
36 36
     }
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
                     );
73 73
                     Session::flash('message', 'File upload successfully!');
74 74
                     // Redirect to index
75
-                } else {
75
+                }else {
76 76
                     Session::flash('message', 'File too large. File must be less than 20MB.');
77 77
                 }
78
-            } else {
78
+            }else {
79 79
                 Session::flash('message', 'Invalid File Extension.');
80 80
             }
81 81
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV);
98 98
             if ($import->failures()->count() > 0) {
99 99
                 $errors = $import->failures();
100
-                $columns =  [
100
+                $columns = [
101 101
                     'remarks',
102 102
                     'st_no',
103 103
                     'stu_no',
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
                 Storage::put($file, implode(',', $columns));
119 119
 
120 120
                 foreach ($errors as $error) {
121
-                    Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values()));
121
+                    Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values()));
122 122
                 }
123 123
             }
124
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
124
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
125 125
         }
126 126
     }
127 127
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
         $students = [];
136 136
         switch ($mode) {
137 137
             case 'duplicate':
138
-                $students =  DB::table('examination_students as es')
138
+                $students = DB::table('examination_students as es')
139 139
                     ->select(DB::raw('count(*) as total'), 'e2.*')
140
-                    ->join('examination_students as e2', 'es.nsid','e2.nsid')
140
+                    ->join('examination_students as e2', 'es.nsid', 'e2.nsid')
141 141
                     ->having('total', '>', 1)
142 142
                     ->groupBy('e2.st_no')
143 143
                     ->orderBy('e2.st_no')
@@ -145,18 +145,18 @@  discard block
 block discarded – undo
145 145
                     ->limit($limit)
146 146
                     ->get()->toArray();
147 147
                 $students = (array) json_decode(json_encode($students));
148
-                $this->output->writeln(count($students) . 'students remaining duplicate');
148
+                $this->output->writeln(count($students).'students remaining duplicate');
149 149
                 array_walk($students, array($this, 'clone'));
150 150
                 $this->output->writeln('All are generated');
151 151
                 break;
152 152
             case 'empty';
153 153
                 $students = Examination_student::whereNull('nsid')
154
-                    ->orWhere('nsid','<>','')
154
+                    ->orWhere('nsid', '<>', '')
155 155
                     ->offset($offset)
156 156
                     ->limit($limit)
157 157
                     ->get()->toArray();
158 158
                 $students = (array) json_decode(json_encode($students));
159
-                $this->output->writeln(count($students) . 'students remaining empty');
159
+                $this->output->writeln(count($students).'students remaining empty');
160 160
                 array_walk($students, array($this, 'clone'));
161 161
                 $this->output->writeln('All are generated');
162 162
                 break;
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
                 ->count();
166 166
                 $all = Examination_student::select('nsid')
167 167
                     ->count();
168
-                $this->output->writeln( $all. 'Total Unique nsid are: ' .$count);
168
+                $this->output->writeln($all.'Total Unique nsid are: '.$count);
169 169
                 break;
170 170
             default:
171 171
                 $students = Examination_student::offset($offset)
172 172
                     ->limit($limit)
173 173
                     ->get()->toArray();
174 174
                 $students = (array) json_decode(json_encode($students));
175
-                $this->output->writeln(count($students) . 'students remaining empty');
175
+                $this->output->writeln(count($students).'students remaining empty');
176 176
                 array_walk($students, array($this, 'clone'));
177 177
                 $this->output->writeln('All are generated');
178 178
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
     public function clone($student)
220 220
     {
221
-        $student = (array)json_decode(json_encode($student));
221
+        $student = (array) json_decode(json_encode($student));
222 222
         //get student matching with same dob and gender
223 223
 
224 224
         $matchedStudent = $this->getMatchingStudents($student);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
                 //TODO implement insert student to admission table
253 253
                 $student['id'] = $sis_student['id'];
254
-                $sis_student['student_id'] =  $student['id'];
254
+                $sis_student['student_id'] = $student['id'];
255 255
 
256 256
                 $student = $this->setIsTakingExam($student);
257 257
                 if (count($institutionClass) == 1) {
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
                     Institution_student::createExaminationData($student, $admissionInfo);
260 260
                     Institution_student_admission::createExaminationData($student, $admissionInfo);
261 261
                     Institution_class_student::createExaminationData($student, $admissionInfo);
262
-                } else {
262
+                }else {
263 263
                     Institution_student_admission::createExaminationData($student, $admissionInfo);
264 264
                     Institution_student::createExaminationData($student, $admissionInfo);
265 265
                 }
266 266
                 $this->updateStudentId($student, $sis_student);
267 267
                 // update the matched student's data    
268
-            } else {
268
+            }else {
269 269
                 $student = $this->setIsTakingExam($student);
270 270
                 $studentData = $this->student->updateExaminationStudent($student, $matchedStudent);
271 271
                 $matchedStudent = array_merge((array) $student, $matchedStudent);
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
                 Institution_student::updateExaminationData($studentData, $admissionInfo);
274 274
                 $this->updateStudentId($student, $studentData);
275 275
             }
276
-        } else {
276
+        }else {
277 277
 
278
-            $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']);
278
+            $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']);
279 279
         }
280 280
     }
281 281
 
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
         ->where('date_of_birth',$student['b_date'])
296 296
          */
297 297
         $sis_student = $this->student->getMatches($student);
298
-        $doe_students =  Examination_student::where('gender',$student['gender'])
299
-            ->where('b_date',$student['b_date'])
300
-            ->where('schoolid',$student['schoolid'])
298
+        $doe_students = Examination_student::where('gender', $student['gender'])
299
+            ->where('b_date', $student['b_date'])
300
+            ->where('schoolid', $student['schoolid'])
301 301
             ->count();
302 302
         $count = $this->student->getStudentCount($student);
303 303
 
304 304
         $studentData = [];
305
-        $sis_users  = (array) json_decode(json_encode($sis_student), true);
305
+        $sis_users = (array) json_decode(json_encode($sis_student), true);
306 306
         // if the same gender same DOE has more than one 
307
-        if(($doe_students > 1) || ($count > 1)){
308
-            $studentData = $this->searchSimilarName($student, $sis_users,false);
309
-        }else{
307
+        if (($doe_students > 1) || ($count > 1)) {
308
+            $studentData = $this->searchSimilarName($student, $sis_users, false);
309
+        }else {
310 310
             $studentData = $this->searchSimilarName($student, $sis_users);
311 311
         }   
312 312
         return $studentData;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      * @param array $sis_students
320 320
      * @return array
321 321
      */
322
-    public function searchSimilarName($student, $sis_students,$surname_search = true)
322
+    public function searchSimilarName($student, $sis_students, $surname_search = true)
323 323
     {
324 324
         $highest = [];
325 325
         $minDistance = 0;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             }
340 340
         }
341 341
 
342
-        if($surname_search){
342
+        if ($surname_search) {
343 343
             if (empty($highest)) {
344 344
                 foreach ($sis_students as $key => $value) {
345 345
                     //search name with last name
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
             }
356 356
         }
357 357
 
358
-        if(count($matches)>1){
359
-            $highest =  $this->searchSimilarName($student, $sis_students,false);
358
+        if (count($matches) > 1) {
359
+            $highest = $this->searchSimilarName($student, $sis_students, false);
360 360
         }
361 361
 
362 362
         return $highest;
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     public function updateStudentId($student, $sis_student)
373 373
     {
374 374
         try {
375
-            $student['nsid'] =  $sis_student['openemis_no'];
375
+            $student['nsid'] = $sis_student['openemis_no'];
376 376
             // add new NSID to the examinations data set
377 377
             unset($student['id']);
378 378
             unset($student['taking_g5_exam']);
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
             unset($student['total']);
382 382
             $this->examination_student->where('st_no', $student['st_no'])->update($student);
383 383
             unset($student['st_no']);
384
-            $this->output->writeln('Updated  to NSID' . $sis_student['openemis_no']);
385
-        } catch (\Exception $th) {
384
+            $this->output->writeln('Updated  to NSID'.$sis_student['openemis_no']);
385
+        }catch (\Exception $th) {
386 386
             dd($th);
387 387
             $this->output->writeln('error');
388 388
             Log::error($th);
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
         try {
401 401
             (new ExaminationStudentsExport)->store('examination/student_data_with_nsid.'.time().'.csv');
402 402
             (new ExportReady($adminUser));
403
-        } catch (\Throwable $th) {
403
+        }catch (\Throwable $th) {
404 404
             //throw $th;
405 405
             dd($th);
406 406
         }
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
     public function downloadErrors()
411 411
     {
412 412
 
413
-        $file_path = storage_path() . '/app/examination/errors.csv';
413
+        $file_path = storage_path().'/app/examination/errors.csv';
414 414
         return Response::download($file_path);
415 415
     }
416 416
 
417 417
     public function downloadProcessedFile()
418 418
     {
419
-        $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv';
419
+        $file_path = storage_path().'/app/examination/student_data_with_nsid.csv';
420 420
         return Response::download($file_path);
421 421
     }
422 422
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -306,7 +306,7 @@
 block discarded – undo
306 306
         // if the same gender same DOE has more than one 
307 307
         if(($doe_students > 1) || ($count > 1)){
308 308
             $studentData = $this->searchSimilarName($student, $sis_users,false);
309
-        }else{
309
+        } else{
310 310
             $studentData = $this->searchSimilarName($student, $sis_users);
311 311
         }   
312 312
         return $studentData;
Please login to merge, or discard this patch.