diff --git a/app/Console/Commands/CallPromotionCommand.php b/app/Console/Commands/CallPromotionCommand.php index b93e737f..89f2ea6d 100755 --- a/app/Console/Commands/CallPromotionCommand.php +++ b/app/Console/Commands/CallPromotionCommand.php @@ -41,6 +41,6 @@ public function handle() { $year = $this->argument('year'); $institution = $this->instituion_grade->getInstitutionGradeList($year); - $this->call('promote:students',['year' => $year,'institution' => $institution->code]); + $this->call('promote:students', ['year' => $year, 'institution' => $institution->code]); } } diff --git a/app/Console/Commands/CloneConfigData.php b/app/Console/Commands/CloneConfigData.php index ce8f455b..f9d8b6ec 100755 --- a/app/Console/Commands/CloneConfigData.php +++ b/app/Console/Commands/CloneConfigData.php @@ -48,8 +48,8 @@ public function __construct() $this->academic_period = new Academic_period(); $this->institution_classes = new Institution_class(); $this->institution_class_subjects = new Institution_class_subject(); - $this->institution_subjects = new Institution_subject(); - $this->education_grade_subjects = new Education_grades_subject(); + $this->institution_subjects = new Institution_subject(); + $this->education_grade_subjects = new Education_grades_subject(); $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); } @@ -76,9 +76,9 @@ public function handle() $this->end_time = microtime(TRUE); - $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); - $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); + $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); + $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); + $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); } @@ -113,13 +113,13 @@ public function process($shift,$count,$params){ $this->output->writeln('updating from '. $shiftId); }catch (\Exception $e){ - Log::error($e->getMessage(),[$e]); + Log::error($e->getMessage(),[$e]); } } // DB::commit(); }catch (\Exception $e){ // DB::rollBack(); - Log::error($e->getMessage(),[$e]); + Log::error($e->getMessage(),[$e]); } } @@ -130,16 +130,16 @@ public function process($shift,$count,$params){ * @param $academicPeriod */ public function insertInstitutionSubjects($subjects, $count,$academicPeriod){ - try{ - $subjects['academic_period_id'] = $academicPeriod->id; - $subjects['created'] = now(); - unset($subjects['total_male_students']); - unset($subjects['total_female_students']); - unset($subjects['id']); - $classSubject = Institution_subject::create($subjects); - }catch (\Exception $e){ + try{ + $subjects['academic_period_id'] = $academicPeriod->id; + $subjects['created'] = now(); + unset($subjects['total_male_students']); + unset($subjects['total_female_students']); + unset($subjects['id']); + $classSubject = Institution_subject::create($subjects); + }catch (\Exception $e){ Log::error($e->getMessage(),[$e]); - } + } } @@ -181,7 +181,7 @@ public function insertInstitutionClasses($class,$count,$param){ $this->insertInstitutionClassSubjects($institutionSubjects,$class); // array_walk($classSubjects,array($this,'insertInstitutionClassSubjects'),$params); }catch (\Exception $e){ - Log::error($e->getMessage(),[$e]); + Log::error($e->getMessage(),[$e]); } } @@ -191,7 +191,7 @@ public function insertInstitutionClassSubjects($subjects,$class){ array_walk($subjects,array($this,'insertClassSubjects'),$class); $this->output->writeln('updating subjects '. $class->name); }catch (\Exception $e){ - Log::error($e->getMessage(),[$e]); + Log::error($e->getMessage(),[$e]); } }; } @@ -209,7 +209,7 @@ public function insertClassSubjects($subject,$count,$newClassId){ $this->institution_class_subjects->create($subjectobj); } }catch (\Exception $e){ - Log::error($e->getMessage(),[$e]); + Log::error($e->getMessage(),[$e]); } } @@ -221,15 +221,15 @@ public function insertClassSubjects($subject,$count,$newClassId){ * @param $academicPeriod * @return array */ - public function generateNewClass($classes,$shiftId,$academicPeriod){ + public function generateNewClass($classes, $shiftId, $academicPeriod) { $newClasses = []; - foreach ( $classes as $class) { + foreach ($classes as $class) { $noOfStudents = $class['no_of_students'] == 0 ? 40 : $class['no_of_students']; $class['academic_period_id'] = $academicPeriod; $class['no_of_students'] = $noOfStudents; $class['created'] = now(); $class['institution_shift_id'] = $shiftId; - array_push($newClasses,$class); + array_push($newClasses, $class); } return $newClasses; } @@ -240,11 +240,11 @@ public function generateNewClass($classes,$shiftId,$academicPeriod){ * @param $shift * @return mixed */ - public function updateShifts($year,$shift){ + public function updateShifts($year, $shift) { $academicPeriod = $this->academic_period->getAcademicPeriod($year); - $this->shifts->where('id',$shift['id'])->update(['cloned' => '2020']); + $this->shifts->where('id', $shift['id'])->update(['cloned' => '2020']); $shift['academic_period_id'] = $academicPeriod->id; $exist = $this->shifts->shiftExists($shift); - return $this->shifts->create((array)$shift)->id; + return $this->shifts->create((array) $shift)->id; } } diff --git a/app/Console/Commands/ImportStudents.php b/app/Console/Commands/ImportStudents.php index be0a75fc..c1767a40 100755 --- a/app/Console/Commands/ImportStudents.php +++ b/app/Console/Commands/ImportStudents.php @@ -47,7 +47,7 @@ class ImportStudents extends Command */ public function __construct() { - $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); + $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); parent::__construct(); } @@ -62,64 +62,64 @@ public function handle() // if(empty($files)){ // $files = $this->getTerminatedFiles(); // } - while ($this->checkTime()){ - if($this->checkTime()){ + while ($this->checkTime()) { + if ($this->checkTime()) { try { - if(!empty($files)){ + if (!empty($files)) { $this->process($files); unset($files); exit(); - }else{ + }else { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $this->output->writeln('No files found,Waiting for files'); exit(); } - }catch (Exception $e){ + }catch (Exception $e) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $this->output->writeln($e); sleep(300); $this->handle(); } - }else{ + }else { exit(); } } } - protected function process($files){ + protected function process($files) { $time = Carbon::now()->tz('Asia/Colombo'); // array_walk($files, array($this,'processSheet')); $node = $this->argument('node'); $files[0]['node'] = $node; $this->processSheet($files[0]); $now = Carbon::now()->tz('Asia/Colombo'); - $this->output->writeln('=============== Time taken to batch ' .$now->diffInMinutes($time)); + $this->output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time)); } - protected function getTerminatedFiles(){ + protected function getTerminatedFiles() { $files = Upload::where('is_processed', '=', 3) ->where('updated_at', '<=', Carbon::now()->tz('Asia/Colombo')->subHours(3)) ->limit(1) - ->orderBy('updated_at','desc') + ->orderBy('updated_at', 'desc') ->get()->toArray(); - if(!empty($files)){ + if (!empty($files)) { $this->output->writeln('******************* Processing a terminated file **********************'); DB::beginTransaction(); DB::table('uploads') ->where('id', $files[0]['id']) - ->update(['is_processed' => 4,'updated_at' => now()]); + ->update(['is_processed' => 4, 'updated_at' => now()]); DB::commit(); } return $files; } - protected function getFiles(){ + protected function getFiles() { $files = Upload::where('is_processed', '=', 0) ->select('uploads.id', 'uploads.security_user_id', 'uploads.institution_class_id', 'uploads.model', 'uploads.filename', 'uploads.is_processed', 'uploads.deleted_at', 'uploads.created_at', @@ -133,85 +133,85 @@ protected function getFiles(){ ->limit(1) ->get()->toArray(); $node = $this->argument('node'); - if(!empty($files)){ + if (!empty($files)) { DB::beginTransaction(); DB::table('uploads') ->where('id', $files[0]['id']) - ->update(['is_processed' => 3,'updated_at' => now(),'node' => $node]); + ->update(['is_processed' => 3, 'updated_at' => now(), 'node' => $node]); DB::commit(); } return $files; } - protected function checkTime(){ + protected function checkTime() { $time = Carbon::now()->tz('Asia/Colombo'); - $morning = Carbon::create($time->year, $time->month, $time->day, env('CRON_START_TIME',0), 29, 0)->tz('Asia/Colombo')->setHour(0); //set time to 05:59 + $morning = Carbon::create($time->year, $time->month, $time->day, env('CRON_START_TIME', 0), 29, 0)->tz('Asia/Colombo')->setHour(0); //set time to 05:59 - $evening = Carbon::create($time->year, $time->month, $time->day, env('CRON_END_TIME',0), 30, 0)->tz('Asia/Colombo')->setHour(23); //set time to 18:00 + $evening = Carbon::create($time->year, $time->month, $time->day, env('CRON_END_TIME', 0), 30, 0)->tz('Asia/Colombo')->setHour(23); //set time to 18:00 - $check = $time->between($morning,$evening, true); + $check = $time->between($morning, $evening, true); return true; } - public function processSuccessEmail($file,$user,$subject) { + public function processSuccessEmail($file, $user, $subject) { $file['subject'] = $subject; $this->output->writeln('Processing the file: '.$file['filename']); try { Mail::to($user->email)->send(new StudentImportSuccess($file)); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 1, 'is_email_sent' => 1,'updated_at' => now()]); - } catch (\Exception $ex) { - $this->output->writeln( $ex->getMessage()); + ->update(['is_processed' => 1, 'is_email_sent' => 1, 'updated_at' => now()]); + }catch (\Exception $ex) { + $this->output->writeln($ex->getMessage()); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 1, 'is_email_sent' => 2,'updated_at' => now()]); + ->update(['is_processed' => 1, 'is_email_sent' => 2, 'updated_at' => now()]); } } - public function processFailedEmail($file,$user,$subject) { + public function processFailedEmail($file, $user, $subject) { $file['subject'] = $subject; try { Mail::to($user->email)->send(new StudentImportFailure($file)); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2, 'is_email_sent' => 1,'updated_at' => now()]); - } catch (\Exception $ex) { - $this->output->writeln( $ex->getMessage()); + ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); + }catch (\Exception $ex) { + $this->output->writeln($ex->getMessage()); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2, 'is_email_sent' => 2,'updated_at' => now()]); + ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]); } } - public function processEmptyEmail($file,$user,$subject) { + public function processEmptyEmail($file, $user, $subject) { $file['subject'] = $subject; try { Mail::to($user->email)->send(new EmptyFile($file)); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2, 'is_email_sent' => 1,'updated_at' => now()]); - } catch (\Exception $ex) { - $this->output->writeln( $ex->getMessage()); + ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); + }catch (\Exception $ex) { + $this->output->writeln($ex->getMessage()); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2, 'is_email_sent' => 2,'updated_at' => now()]); + ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]); } } - protected function checkNode($file){ + protected function checkNode($file) { $node = $this->argument('node'); - if($node == $file['node']){ + if ($node == $file['node']) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); - $this->output->writeln('Processing from:' . $node); + $this->output->writeln('Processing from:'.$node); return true; - }else{ + }else { exit; return false; } } - protected function processSheet($file){ + protected function processSheet($file) { $this->startTime = Carbon::now()->tz('Asia/Colombo'); $user = User::find($file['security_user_id']); $this->checkNode($file); @@ -219,39 +219,39 @@ protected function processSheet($file){ $this->output->writeln('Processing the file: '.$file['filename']); if ($this->checkTime()) { try { - $this->import($file,1,'C'); + $this->import($file, 1, 'C'); sleep(10); - $this->import($file,2,'B'); + $this->import($file, 2, 'B'); - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { - $this->output->writeln( $e->getMessage()); + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { + $this->output->writeln($e->getMessage()); try { Mail::to($user->email)->send(new IncorrectTemplate($file)); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2, 'is_email_sent' => 1,'updated_at' => now()]); - } catch (\Exception $ex) { - $this->output->writeln( $e->getMessage()); + ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); + }catch (\Exception $ex) { + $this->output->writeln($e->getMessage()); $this->handle(); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2, 'is_email_sent' => 2 ,'updated_at' => now()]); + ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]); } } - } else { + }else { exit(); } } - protected function getType($file){ - $file = storage_path() . '/app/sis-bulk-data-files/'.$file; - $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file); + protected function getType($file) { + $file = storage_path().'/app/sis-bulk-data-files/'.$file; + $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file); return $inputFileType; } - protected function getSheetWriter($file,$reader){ - switch ($this->getType($file['filename'])){ + protected function getSheetWriter($file, $reader) { + switch ($this->getType($file['filename'])) { case 'Xlsx': return new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($reader); break; @@ -267,8 +267,8 @@ protected function getSheetWriter($file,$reader){ } } - protected function getSheetType($file){ - switch ($this->getType($file)){ + protected function getSheetType($file) { + switch ($this->getType($file)) { case 'Xlsx': return \Maatwebsite\Excel\Excel::XLSX; break; @@ -286,8 +286,8 @@ protected function getSheetType($file){ protected function getSheetCount($file){ - $objPHPExcel = $this->setReader($file); - return $objPHPExcel->getSheetCount(); + $objPHPExcel = $this->setReader($file); + return $objPHPExcel->getSheetCount(); } @@ -298,8 +298,8 @@ protected function getSheetCount($file){ * @param $column */ protected function import($file, $sheet, $column){ - try { - ini_set('memory_limit', '2048M'); + try { + ini_set('memory_limit', '2048M'); $this->getFileSize($file); $user = User::find($file['security_user_id']); $excelFile = '/sis-bulk-data-files/' . $file['filename']; @@ -321,11 +321,11 @@ protected function import($file, $sheet, $column){ ->update(['insert' => 3,'updated_at' => now()]); $this->processFailedEmail($file,$user,'Fresh Student Data Upload:Partial Success '); $this->stdOut('Insert Students',$this->higestRow); - }else{ + } else{ $this->processSuccessEmail($file,$user,'Fresh Student Data Upload:Success '); $this->stdOut('Insert Students',$this->higestRow); } - }else if(($this->getSheetName($file,'Insert Students')) && $this->higestRow > 0) { + } else if(($this->getSheetName($file,'Insert Students')) && $this->higestRow > 0) { DB::table('uploads') ->where('id', $file['id']) ->update(['is_processed' => 2]); @@ -347,11 +347,11 @@ protected function import($file, $sheet, $column){ ->update(['update' => 3,'is_processed' => 1,'updated_at' => now()]); $this->processFailedEmail($file,$user,'Existing Student Data Update:Partial Success '); $this->stdOut('Update Students',$this->higestRow); - }else{ + } else{ $this->processSuccessEmail($file,$user, 'Existing Student Data Update:Success '); $this->stdOut('Update Students',$this->higestRow); } - }else if(($this->getSheetName($file,'Update Students')) && $this->higestRow == 0) { + } else if(($this->getSheetName($file,'Update Students')) && $this->higestRow == 0) { DB::table('uploads') ->where('id', $file['id']) ->update(['is_processed' => 2,'updated_at' => now()]); @@ -360,23 +360,23 @@ protected function import($file, $sheet, $column){ break; } }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { - $this->output->writeln( $e->getMessage()); - if($sheet == 1){ - self::writeErrors($e,$file,'Insert Students'); - DB::table('uploads') - ->where('id', $file['id']) - ->update(['insert' => 2,'updated_at' => now()]); + $this->output->writeln( $e->getMessage()); + if($sheet == 1){ + self::writeErrors($e,$file,'Insert Students'); + DB::table('uploads') + ->where('id', $file['id']) + ->update(['insert' => 2,'updated_at' => now()]); $this->processFailedEmail($file,$user,'Fresh Student Data Upload:Failed'); - }else if($sheet == 2){ - self::writeErrors($e,$file,'Update Students'); - DB::table('uploads') - ->where('id', $file['id']) - ->update(['update' => 2,'updated_at' => now()]); + }else if($sheet == 2){ + self::writeErrors($e,$file,'Update Students'); + DB::table('uploads') + ->where('id', $file['id']) + ->update(['update' => 2,'updated_at' => now()]); $this->processFailedEmail($file,$user, 'Existing Student Data Update:Failed'); - } - DB::table('uploads') - ->where('id', $file['id']) - ->update(['is_processed' =>2 , 'updated_at' => now()]); + } + DB::table('uploads') + ->where('id', $file['id']) + ->update(['is_processed' =>2 , 'updated_at' => now()]); } @@ -399,7 +399,7 @@ protected function getFileSize($file){ $user = User::find($file['security_user_id']); if( $size > 0){ return true; - }else{ + } else{ DB::table('uploads') ->where('id', $file['id']) ->update(['is_processed' =>2 , 'updated_at' => now()]); @@ -420,7 +420,7 @@ protected function setReader($file){ $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->getType($file['filename'])); $objPHPExcel = $reader->load($excelFile); return $objPHPExcel; - }catch (Exception $e){ + } catch (Exception $e){ $this->output->writeln( $e->getMessage()); $user = User::find($file['security_user_id']); DB::table('uploads') @@ -435,7 +435,7 @@ protected function getSheetName($file,$sheet){ try{; $objPHPExcel = $this->setReader($file); return $objPHPExcel->getSheetByName($sheet) !== null; - }catch (Exception $e){ + } catch (Exception $e){ $this->output->writeln( $e->getMessage()); $user = User::find($file['security_user_id']); DB::table('uploads') @@ -461,7 +461,7 @@ protected function getHigestRow($file,$sheet,$column){ } } return $higestRow; - }catch(\Exception $e){ + } catch(\Exception $e){ $this->output->writeln( $e->getMessage()); $user = User::find($file['security_user_id']); DB::beginTransaction(); @@ -510,39 +510,39 @@ protected function writeErrors($e,$file,$sheet){ $reader = $this->setReader($file); $reader->setActiveSheetIndexByName($sheet); - $failures = gettype($failures) == 'object' ? array_map(array($this,'processErrors'),iterator_to_array($failures)) : array_map(array($this,'processErrors'),($failures)); - if(count($failures) > 0){ - $rows = array_map('rows',$failures); + $failures = gettype($failures) == 'object' ? array_map(array($this, 'processErrors'), iterator_to_array($failures)) : array_map(array($this, 'processErrors'), ($failures)); + if (count($failures) > 0) { + $rows = array_map('rows', $failures); $rows = array_unique($rows); - $rowIndex = range(3,$this->higestRow+2); + $rowIndex = range(3, $this->higestRow + 2); $params = [ 'rows' =>$rows, 'reader' => $reader ]; - array_walk($failures , 'append_errors_to_excel',$reader); - array_walk($rowIndex , array($this,'removeRows'),$params); - $objWriter = $this->getSheetWriter($file,$reader); + array_walk($failures, 'append_errors_to_excel', $reader); + array_walk($rowIndex, array($this, 'removeRows'), $params); + $objWriter = $this->getSheetWriter($file, $reader); Storage::disk('local')->makeDirectory('sis-bulk-data-files/processed'); - $objWriter->save(storage_path() . '/app/sis-bulk-data-files/processed/' . $file['filename']); + $objWriter->save(storage_path().'/app/sis-bulk-data-files/processed/'.$file['filename']); $now = Carbon::now()->tz('Asia/Colombo'); - $this->output->writeln( $reader->getActiveSheet()->getTitle() . ' Process completed at . '.' '. now()); + $this->output->writeln($reader->getActiveSheet()->getTitle().' Process completed at . '.' '.now()); $this->output->writeln('memory usage for the processes : '.(memory_get_usage() - $baseMemory)); - $this->output->writeln( 'Time taken to process : '. $now->diffInSeconds($this->startTime) .' Seconds'); + $this->output->writeln('Time taken to process : '.$now->diffInSeconds($this->startTime).' Seconds'); $this->output->writeln(' errors reported : '.count($failures)); $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------'); unset($objWriter); unset($failures); } - }catch (Eception $e){ - $this->output->writeln( $e->getMessage()); + }catch (Eception $e) { + $this->output->writeln($e->getMessage()); $user = User::find($file['security_user_id']); DB::beginTransaction(); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 2,'updated_at' => now()]); + ->update(['is_processed' => 2, 'updated_at' => now()]); DB::commit(); - $this->processEmptyEmail($file,$user, 'No valid data found'); + $this->processEmptyEmail($file, $user, 'No valid data found'); exit(); } } diff --git a/app/Console/Commands/ProcessTerminatedFiles.php b/app/Console/Commands/ProcessTerminatedFiles.php index d25202d2..7c9d9640 100755 --- a/app/Console/Commands/ProcessTerminatedFiles.php +++ b/app/Console/Commands/ProcessTerminatedFiles.php @@ -45,19 +45,19 @@ public function handle() { $files = $this->getFiles(); try { - if(!empty($files)){ - array_walk($files,array($this,'process')); + if (!empty($files)) { + array_walk($files, array($this, 'process')); unset($files); exit(); - }else{ + }else { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $output->writeln('No files found,Waiting for files'); exit(); } - }catch (Exception $e){ + }catch (Exception $e) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $output->writeln($e); sleep(300); @@ -67,25 +67,25 @@ public function handle() } - protected function getFiles(){ + protected function getFiles() { $files = Upload::where('is_processed', '=', 3) - ->where('is_email_sent','=',0) + ->where('is_email_sent', '=', 0) ->where('updated_at', '<=', Carbon::now()->tz('Asia/Colombo')->subHours(3)) ->limit(50) ->get()->toArray(); return $files; } - protected function process($file){ + protected function process($file) { $time = Carbon::now()->tz('Asia/Colombo'); $this->processSheet($file); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $now = Carbon::now()->tz('Asia/Colombo'); - $output->writeln('=============== Time taken to batch ' .$now->diffInMinutes($time)); + $output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time)); } - protected function processSheet($file){ + protected function processSheet($file) { $this->startTime = Carbon::now()->tz('Asia/Colombo'); $user = User::find($file['security_user_id']); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); @@ -95,8 +95,8 @@ protected function processSheet($file){ Mail::to($user->email)->send(new TerminatedReport($file)); DB::table('uploads') ->where('id', $file['id']) - ->update(['is_processed' => 3, 'is_email_sent' => 1,'updated_at' => now()]); - } else { + ->update(['is_processed' => 3, 'is_email_sent' => 1, 'updated_at' => now()]); + }else { exit(); } } diff --git a/app/Console/Commands/PromoteStudents.php b/app/Console/Commands/PromoteStudents.php index a27c8e14..70336e03 100755 --- a/app/Console/Commands/PromoteStudents.php +++ b/app/Console/Commands/PromoteStudents.php @@ -63,14 +63,14 @@ public function handle() { $year = $this->argument('year'); $institution = $this->argument('institution'); - $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($year,$institution); + $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($year, $institution); // dd($institutionGrade); - array_walk($institutionGrade,array($this,'processGrades'),$year); + array_walk($institutionGrade, array($this, 'processGrades'), $year); } - public function processGrades($institutionGrade,$count,$year){ - if(!empty($institutionGrade) && $this->institutions->isActive($institutionGrade['institution_id'])) { - $this->instituion_grade->updatePromoted($year,$institutionGrade['id']); + public function processGrades($institutionGrade, $count, $year) { + if (!empty($institutionGrade) && $this->institutions->isActive($institutionGrade['institution_id'])) { + $this->instituion_grade->updatePromoted($year, $institutionGrade['id']); $isAvailableforPromotion = 0; $nextGrade = $this->education_grades->getNextGrade($institutionGrade['education_grade_id']); @@ -79,9 +79,9 @@ public function processGrades($institutionGrade,$count,$year){ } if (!empty($isAvailableforPromotion)) { - $this->process($institutionGrade,$nextGrade,$year,1); - }else{ - $this->process($institutionGrade,$nextGrade,$year,3); + $this->process($institutionGrade, $nextGrade, $year, 1); + }else { + $this->process($institutionGrade, $nextGrade, $year, 3); } } } @@ -97,9 +97,9 @@ public function processGrades($institutionGrade,$count,$year){ * @param array $parallelClasses * @param $status */ - public function promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$parallelClasses = [],$status){ - $institution = Institution::where( 'id',$institutionGrade['institution_id'])->get()->first(); - $studentListToPromote = $this->institution_students->getStudentListToPromote($institutionGrade,$academicPeriod); + public function promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $parallelClasses = [], $status) { + $institution = Institution::where('id', $institutionGrade['institution_id'])->get()->first(); + $studentListToPromote = $this->institution_students->getStudentListToPromote($institutionGrade, $academicPeriod); $params = [ $nextAcademicPeriod, @@ -108,15 +108,15 @@ public function promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcad $status ]; - try{ - array_walk($studentListToPromote,array($this,'promote'),$params); + try { + array_walk($studentListToPromote, array($this, 'promote'), $params); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $output->writeln('##########################################################################################################################'); - $output->writeln('Promoting from '. $institutionGrade['name'] .' IN '.$institution->name.' No of Students: '. count($studentListToPromote)); + $output->writeln('Promoting from '.$institutionGrade['name'].' IN '.$institution->name.' No of Students: '.count($studentListToPromote)); - if(!empty($parallelClasses)){ + if (!empty($parallelClasses)) { $params = [ $nextAcademicPeriod, $institutionGrade, @@ -124,10 +124,10 @@ public function promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcad $parallelClasses, $status ]; - array_walk($studentListToPromote,array($this,'assingeToClasses'),$params); - array_walk($parallelClasses,array($this,'updateStudentCount')); + array_walk($studentListToPromote, array($this, 'assingeToClasses'), $params); + array_walk($parallelClasses, array($this, 'updateStudentCount')); } - }catch (\Exception $e){ + }catch (\Exception $e) { dd($e); Log::error($e->getMessage()); } @@ -135,10 +135,10 @@ public function promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcad - public function updateStudentCount($class){ + public function updateStudentCount($class) { $studentCounts = Institution_class_student::getStudentsCount($class['id']); unset($studentCounts['total']); - Institution_class::query()->where('id',$class['id'])->update($studentCounts); + Institution_class::query()->where('id', $class['id'])->update($studentCounts); } @@ -150,38 +150,38 @@ public function updateStudentCount($class){ * @param $year * @return int */ - public function process($institutionGrade,$nextGrade,$year){ - $academicPeriod = Academic_period::query()->where('code',$year -1)->get()->first(); - $nextAcademicPeriod = Academic_period::query()->where('code',$year)->get()->first(); + public function process($institutionGrade, $nextGrade, $year) { + $academicPeriod = Academic_period::query()->where('code', $year - 1)->get()->first(); + $nextAcademicPeriod = Academic_period::query()->where('code', $year)->get()->first(); $nextGradeObj = null; - if($nextGrade !== [] && !is_null($nextGrade) ){ - $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'],$institutionGrade['institution_id'],$institutionGrade['education_grade_id'],$academicPeriod->id); - $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'],$institutionGrade['institution_id'],$nextGrade->id,$nextAcademicPeriod->id); + if ($nextGrade !== [] && !is_null($nextGrade)) { + $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $institutionGrade['education_grade_id'], $academicPeriod->id); + $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $nextGrade->id, $nextAcademicPeriod->id); } - if(!is_null($nextGradeObj)){ - if($nextGradeObj->count() == 1){ + if (!is_null($nextGradeObj)) { + if ($nextGradeObj->count() == 1) { // promote parallel classes - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$nextGradeObj->toArray(),1); + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $nextGradeObj->toArray(), 1); return 1; - }elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())){ + }elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { // promote pool promotion - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],1); + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 1); return 2; - }elseif(($nextGradeObj->count() > 1) && $currentGradeObj->count() == $nextGradeObj->count()){ + }elseif (($nextGradeObj->count() > 1) && $currentGradeObj->count() == $nextGradeObj->count()) { // Promote matching class name with previous class - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,$nextGradeObj->toArray(),1); + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, $nextGradeObj->toArray(), 1); return 1; - }else{ + }else { // default pool promotion - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],1); + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 1); return 2; } - }else{ + }else { // default pool promotion - $this->promotion($institutionGrade,$nextGrade,$academicPeriod,$nextAcademicPeriod,[],3); + $this->promotion($institutionGrade, $nextGrade, $academicPeriod, $nextAcademicPeriod, [], 3); return 2; } } @@ -194,7 +194,7 @@ public function process($institutionGrade,$nextGrade,$year){ * @param $count * @param $params */ - public function promote($student,$count,$params){ + public function promote($student, $count, $params) { $academicPeriod = $params[0]; $nextGrade = $params[2]; @@ -212,11 +212,11 @@ public function promote($student,$count,$params){ 'created_user_id' => $student['created_user_id'] ]; try{ - Institution_student::where('id',(string)$student['id'])->update($studentData); + Institution_student::where('id',(string)$student['id'])->update($studentData); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $output->writeln('----------------- '. $student['admission_id'] . ' to ' . $studentData['education_grade_id']); - }catch (\Exception $e){ + } catch (\Exception $e){ dd($e); Log::error($e->getMessage()); } @@ -232,11 +232,11 @@ public function promote($student,$count,$params){ * @param $classes * @return false|int|string|null */ - public function getStudentClass($student,$educationGrade,$nextGrade,$classes){ + public function getStudentClass($student, $educationGrade, $nextGrade, $classes) { $studentClass = $this->institution_class_students->getStudentNewClass($student); - if(!is_null($studentClass)){ - return array_search(str_replace($educationGrade['name'],$nextGrade->name,$studentClass->name),array_column($classes,'name')); - }else{ + if (!is_null($studentClass)) { + return array_search(str_replace($educationGrade['name'], $nextGrade->name, $studentClass->name), array_column($classes, 'name')); + }else { return false; } @@ -249,7 +249,7 @@ public function getStudentClass($student,$educationGrade,$nextGrade,$classes){ * @param $count * @param $params */ - public function assingeToClasses($student,$count,$params){ + public function assingeToClasses($student, $count, $params) { $academicPeriod = $params[0]; $educationGrade = $params[1]; $nextGrade = $params[2]; @@ -257,15 +257,15 @@ public function assingeToClasses($student,$count,$params){ $status = $params[4]; - $class = $this->getStudentClass($student,$educationGrade,$nextGrade,$classes); - if(is_numeric($class)){ + $class = $this->getStudentClass($student, $educationGrade, $nextGrade, $classes); + if (is_numeric($class)) { $class = $classes[$class]; - if(count($classes) == 1){ + if (count($classes) == 1) { $class = $classes[0]; } - if(!is_null($class)){ + if (!is_null($class)) { $studentObj = [ 'student_id' => $student['student_id'], @@ -276,14 +276,14 @@ public function assingeToClasses($student,$count,$params){ 'student_status_id' => $status, 'created_user_id' => $student['created_user_id'] ]; - if(!$this->institution_class_students->isDuplicated($studentObj)){ + if (!$this->institution_class_students->isDuplicated($studentObj)) { $this->institution_class_students->create($studentObj); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); - $output->writeln('----------------- '. $student['student_id']. 'to ' . $class['name']); - }else{ - $this->institution_class_students->where('id',(string)$student['id'])->update($studentObj); + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); + }else { + $this->institution_class_students->where('id', (string) $student['id'])->update($studentObj); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); - $output->writeln('----------------- '. $student['student_id']. 'to ' . $class['name']); + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); } } } diff --git a/app/Console/Commands/RunAddApprovedStudents.php b/app/Console/Commands/RunAddApprovedStudents.php index 6a5d0069..008527c6 100755 --- a/app/Console/Commands/RunAddApprovedStudents.php +++ b/app/Console/Commands/RunAddApprovedStudents.php @@ -78,41 +78,41 @@ protected function addStudent($student){ $this->count += 1; $this->student = $student ; try{ - Institution_student::create([ - 'student_status_id' => 1, - 'student_id' => $student['student_id'], - 'education_grade_id' => $student['education_grade_id'], - 'academic_period_id' => $student['academic_period_id'], - 'start_date' => $student['start_date'], - 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['start_date'])->year , // $student['start_date']->format('Y'), - 'end_date' => $student['end_date'], - 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['end_date'])->year , //$student['end_date']->format('Y'), - 'institution_id' => $student['institution_id'], - 'admission_id' => $student['admission_id'], - 'created_user_id' => $student['created_user_id'], - ]); - - if(!is_null($student['institution_class_id'])){ - Institution_class_student::create([ - 'student_id' => $student['student_id'], - 'institution_class_id' => $student['institution_class_id'], - 'education_grade_id' => $student['education_grade_id'], - 'academic_period_id' => $student['academic_period_id'], - 'institution_id' =>$student['institution_id'], - 'student_status_id' => 1, - 'created_user_id' => $student['created_user_id'], - ]); - } + Institution_student::create([ + 'student_status_id' => 1, + 'student_id' => $student['student_id'], + 'education_grade_id' => $student['education_grade_id'], + 'academic_period_id' => $student['academic_period_id'], + 'start_date' => $student['start_date'], + 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['start_date'])->year , // $student['start_date']->format('Y'), + 'end_date' => $student['end_date'], + 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['end_date'])->year , //$student['end_date']->format('Y'), + 'institution_id' => $student['institution_id'], + 'admission_id' => $student['admission_id'], + 'created_user_id' => $student['created_user_id'], + ]); + + if(!is_null($student['institution_class_id'])){ + Institution_class_student::create([ + 'student_id' => $student['student_id'], + 'institution_class_id' => $student['institution_class_id'], + 'education_grade_id' => $student['education_grade_id'], + 'academic_period_id' => $student['academic_period_id'], + 'institution_id' =>$student['institution_id'], + 'student_status_id' => 1, + 'created_user_id' => $student['created_user_id'], + ]); + } $output->writeln(' #################################################### Total number of students updated : '.$this->count.' # # ####################################################' ); // $output->writeln(); - }catch (\Exception $e){ + }catch (\Exception $e){ // echo $e->getMessage(); - $output->writeln( $e->getMessage()); - } + $output->writeln( $e->getMessage()); + } } } @@ -133,7 +133,7 @@ protected function setSubjects($student){ } - protected function setStudentSubjects($subject){ + protected function setStudentSubjects($subject) { return [ 'id' => (string) Uuid::generate(4), 'student_id' => $this->student->student_id, @@ -149,8 +149,8 @@ protected function setStudentSubjects($subject){ ]; } - protected function insertSubject($subject){ - if(!Institution_subject_student::isDuplicated($subject)){ + protected function insertSubject($subject) { + if (!Institution_subject_student::isDuplicated($subject)) { Institution_subject_student::updateOrInsert($subject); } } diff --git a/app/Console/Commands/StudentsIdGen.php b/app/Console/Commands/StudentsIdGen.php index 10fd814a..366c31a3 100755 --- a/app/Console/Commands/StudentsIdGen.php +++ b/app/Console/Commands/StudentsIdGen.php @@ -46,16 +46,16 @@ public function handle() $this->start_time = microtime(TRUE); ini_set('memory_limit', '2048M'); $students = $this->students->query() - ->where('is_student',1) + ->where('is_student', 1) ->limit(100000) ->offset($this->argument('offset')) ->get()->toArray(); $this->output->writeln('no of students'.count($students)); $this->output->writeln('Update started'); - array_walk($students,array($this,'updateNewUUID')); + array_walk($students, array($this, 'updateNewUUID')); $this->end_time = microtime(TRUE); $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); } @@ -64,12 +64,12 @@ public function handle() * @param $student * @throws \Exception */ - public function updateNewUUID($student){ - if(!MoeUuid::isValidMoeUuid(3)){ + public function updateNewUUID($student) { + if (!MoeUuid::isValidMoeUuid(3)) { $newId = MoeUuid::getUniqueAlphanumeric(3); $this->output->writeln('Updating student:'.$student['id']); - Security_user::query()->where('id',$student['id']) - ->update(['openemis_no' => $newId , 'username' => str_replace('-','',$newId)]); + Security_user::query()->where('id', $student['id']) + ->update(['openemis_no' => $newId, 'username' => str_replace('-', '', $newId)]); } } } diff --git a/app/Console/Commands/callAddApprovedStudents.php b/app/Console/Commands/callAddApprovedStudents.php index dab558e2..1c693629 100755 --- a/app/Console/Commands/callAddApprovedStudents.php +++ b/app/Console/Commands/callAddApprovedStudents.php @@ -39,17 +39,17 @@ public function __construct() */ public function handle() { - ini_set('memory_limit','2048'); + ini_set('memory_limit', '2048'); $institutions = $this->instituions->all()->chunk(50)->toArray(); - array_walk($institutions,array($this,'addInstitutionStudents')); + array_walk($institutions, array($this, 'addInstitutionStudents')); } - protected function addInstitutionStudents($chunk){ - array_walk($chunk,array($this,'callFunction')); + protected function addInstitutionStudents($chunk) { + array_walk($chunk, array($this, 'callFunction')); } - protected function callFunction($institution){ - $this->call('admission:students',['institution' => $institution['code']]); + protected function callFunction($institution) { + $this->call('admission:students', ['institution' => $institution['code']]); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3842f722..743fdfbd 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -25,8 +25,8 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('import:students') - ->cron('* * * * * '); + $schedule->command('import:students') + ->cron('* * * * * '); } /** diff --git a/app/Exports/UsersExport.php b/app/Exports/UsersExport.php index 0ca7b687..ce4ec34f 100755 --- a/app/Exports/UsersExport.php +++ b/app/Exports/UsersExport.php @@ -31,12 +31,12 @@ class UsersExport implements FromCollection, WithEvents, WithStartRow, WithMulti public function __construct($class) { $this->class = $class; - $this->_file_name = time() . '_' . Auth::user()->id . '_' . 'student_upload.xls'; + $this->_file_name = time().'_'.Auth::user()->id.'_'.'student_upload.xls'; } public function registerEvents(): array { return [ - BeforeSheet::class => function(BeforeSheet $event){ + BeforeSheet::class => function(BeforeSheet $event) { // dd($event->crea) }, BeforeWriting::class => function(BeforeWriting $event) { @@ -63,7 +63,7 @@ public function collection() { $class = $this->class; return Security_user::select('openemis_no', 'first_name', 'gender_id', 'date_of_birth', 'address', 'birthplace_area_id') ->with(['class', 'special_needs']) - ->whereHas('class', function ($query) use ($class) { + ->whereHas('class', function($query) use ($class) { $query->where('institution_class_id', '=', $class); }) ->get(); diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index ae4e68db..a2407f1a 100755 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -54,10 +54,10 @@ public function authorize($ability, $arguments = []) /** * @return string */ - public function findUsername(){ + public function findUsername() { $login = request()->input('username'); - $fieldType = filter_var($login,FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; + $fieldType = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; request()->merge([$fieldType => $login]); @@ -67,7 +67,7 @@ public function findUsername(){ /** * @return string */ - public function username(){ + public function username() { return $this->username; } } diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php index 1c7aeb94..0dd6a964 100755 --- a/app/Http/Controllers/FileController.php +++ b/app/Http/Controllers/FileController.php @@ -34,7 +34,7 @@ public function __construct() * @param Request $request * @return \Illuminate\Http\JsonResponse */ - public function upload(Request $request){ + public function upload(Request $request) { @@ -76,7 +76,7 @@ public function upload(Request $request){ $institution = auth()->user()->permissions->isEmpty() ? auth()->user()->principal[0]->institution_group[0]->institution->code : auth()->user()->permissions[0]->institution_staff->institution->code; - $fileName = time().'_'.$institution.'_'.str_replace(' ','_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; + $fileName = time().'_'.$institution.'_'.str_replace(' ', '_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; Storage::disk('local')->putFileAs( 'sis-bulk-data-files/', $uploadFile, @@ -84,7 +84,7 @@ public function upload(Request $request){ ); $upload = new Upload; - $upload->fileName =$fileName; + $upload->fileName = $fileName; $upload->model = 'Student'; $upload->node = 'None'; $upload->institution_class_id = $class->id; @@ -95,12 +95,12 @@ public function upload(Request $request){ return redirect('/')->withSuccess('The file is uploaded, we will process and let you know by your email'); } - public function updateQueueWithUnprocessedFiles($id, $action){ - if($action == 100){ + public function updateQueueWithUnprocessedFiles($id, $action) { + if ($action == 100) { DB::table('uploads') ->where('id', $id) ->update(['is_processed' => 0]); - }elseif ($action == 200) { + } elseif ($action == 200) { DB::table('uploads') ->where('id', $id) ->update(['is_processed' => 4]); @@ -108,17 +108,16 @@ public function updateQueueWithUnprocessedFiles($id, $action){ } - public function downloadTemplate(){ + public function downloadTemplate() { $filename = 'censusNo_className_sis_students_bulk_upload'; $version = '2007_V1.7_20200510.xlsx'; - $file_path = storage_path() .'/app/public/'. $filename.'_'.$version;; + $file_path = storage_path().'/app/public/'.$filename.'_'.$version; ; if (file_exists($file_path)) { return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ - 'Content-Length: '. filesize($file_path) + 'Content-Length: '.filesize($file_path) ]); - } - else + } else { return View::make('errors.404'); } @@ -129,31 +128,29 @@ public function downloadTemplate(){ * @param $filename * @return Processed excel file with error */ - public function downloadErrorFile($filename){ + public function downloadErrorFile($filename) { - $file_path = storage_path().'/app/sis-bulk-data-files/processed/'. $filename; + $file_path = storage_path().'/app/sis-bulk-data-files/processed/'.$filename; if (file_exists($file_path)) { return Response::download($file_path, $filename, [ - 'Content-Length: '. filesize($file_path) + 'Content-Length: '.filesize($file_path) ]); - } - else + } else { abort(404, 'We did not found an error file.'); } } - public function downloadFile($filename){ - $file_path = storage_path().'/app/sis-bulk-data-files/'. $filename; + public function downloadFile($filename) { + $file_path = storage_path().'/app/sis-bulk-data-files/'.$filename; if (file_exists($file_path)) { return Response::download($file_path, $filename, [ - 'Content-Length: '. filesize($file_path) + 'Content-Length: '.filesize($file_path) ]); - } - else + } else { abort(404, 'We did not found an error file.'); diff --git a/app/Http/Controllers/FilesController.php b/app/Http/Controllers/FilesController.php index 219f2f9c..c32b34b8 100755 --- a/app/Http/Controllers/FilesController.php +++ b/app/Http/Controllers/FilesController.php @@ -23,16 +23,15 @@ public function index() if($diff_in_hours >= 2 && $data->is_processed == 3){ return "Terminated"; - } - elseif ($data->is_processed === 1) { + } elseif ($data->is_processed === 1) { return "Success"; - }elseif ($data->is_processed === 2){ + } elseif ($data->is_processed === 2){ return "Failed"; - }elseif($diff_in_hours < 2 && $data->is_processed == 3){ + } elseif($diff_in_hours < 2 && $data->is_processed == 3){ return "Processing"; - }elseif ($data->is_processed == 4){ + } elseif ($data->is_processed == 4){ return "Process Paused"; - }else{ + } else{ return 'Pending'; }; @@ -40,9 +39,9 @@ public function index() ->editColumn('is_email_sent', function ($data) { if ($data->is_email_sent === 1) { return "Success"; - }elseif($data->is_email_sent === 2 ){ + } elseif($data->is_email_sent === 2 ){ return 'Failed'; - }else{ + } else{ return 'Pending'; }; @@ -50,11 +49,11 @@ public function index() ->editColumn('update', function ($data) { if ($data->update === 0) { return "No Processes"; - }elseif($data->update === 1 ){ + } elseif($data->update === 1 ){ return 'Success'; - }elseif($data->update === 3 ){ + } elseif($data->update === 3 ){ return 'Partial Success'; - }else{ + } else{ return 'Failed'; }; @@ -62,11 +61,11 @@ public function index() ->editColumn('insert', function ($data) { if ($data->insert === 0) { return "No Processes"; - }elseif($data->insert === 1 ){ + } elseif($data->insert === 1 ){ return 'Success'; - }elseif($data->insert === 3 ){ + } elseif($data->insert === 3 ){ return 'Partial Success'; - }else{ + } else{ return 'Failed'; }; @@ -74,7 +73,7 @@ public function index() ->editColumn('filename', function ($data) { return 'filename.'>'.substr($data->classRoom->name, 0, 10).''; }) - ->editColumn('error', function ($data) { + ->editColumn('error', function ($data) { return 'filename.'>'.substr($data->classRoom->name, 0, 10).''; })->editColumn('actions', function ($data) { @@ -85,13 +84,13 @@ public function index() if($diff_in_hours >= 2 && $data->is_processed == 3){ return ''; - }elseif ($data->is_processed == 1){ + } elseif ($data->is_processed == 1){ return '
Processing Successful
'; - }elseif ($data->is_processed == 2){ + } elseif ($data->is_processed == 2){ return '
Processing Failed
'; - }elseif ($data->is_processed == 0){ + } elseif ($data->is_processed == 0){ return ''; - }elseif ($data->is_processed == 4){ + } elseif ($data->is_processed == 4){ return ''; } }) diff --git a/app/Http/Controllers/ImportExport.php b/app/Http/Controllers/ImportExport.php index dc80e21b..5d1bd901 100755 --- a/app/Http/Controllers/ImportExport.php +++ b/app/Http/Controllers/ImportExport.php @@ -29,24 +29,24 @@ public function __construct() } - /** - * @return \Illuminate\Support\Collection - */ + /** + * @return \Illuminate\Support\Collection + */ public function importExportView() { - $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; + $classes = (!Auth::user()->permissions->isEmpty()) ? Auth::user()->permissions[0]->staff_class : Auth::user()->principal[0]->security_group_institution->institution_classes; - return view('importExport')->with('classes',$classes); + return view('importExport')->with('classes', $classes); } /** - * @return \Illuminate\Support\Collection - */ + * @return \Illuminate\Support\Collection + */ public function export(Request $request) { - $request->validate([ + $request->validate([ 'class' => 'required' ]); return Excel::download(new UsersExport($request->input('class')), 'users.xlsx'); @@ -55,8 +55,8 @@ public function export(Request $request) /** - * @return \Illuminate\Support\Collection - */ + * @return \Illuminate\Support\Collection + */ public function import(Request $request) { @@ -70,9 +70,9 @@ public function import(Request $request) $import = new UsersImport(); - try{ + try { $files = Storage::disk('sis-bulk-data-files')->allFiles(); - Excel::import($import,request()->file('import_file')); + Excel::import($import, request()->file('import_file')); }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { $failures = $e->failures(); diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index a4be5c58..fd123fd4 100755 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -14,7 +14,7 @@ class Authenticate extends Middleware */ protected function redirectTo($request) { - if (! $request->expectsJson()) { + if (!$request->expectsJson()) { return route('login'); } } diff --git a/app/Http/Middleware/classTeacher.php b/app/Http/Middleware/classTeacher.php index 20f14b74..b200040d 100755 --- a/app/Http/Middleware/classTeacher.php +++ b/app/Http/Middleware/classTeacher.php @@ -16,11 +16,11 @@ class classTeacher public function handle($request, Closure $next) { // dd($request->user()->permissions); - if ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { + if ($request->user() && (!($request->user()->permissions->isEmpty())) && $request->user()->permissions[0]->roles && $request->user()->permissions[0]->roles->code === 'HOMEROOM_TEACHER') { return $next($request); - }elseif($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL'){ + }elseif ($request->user() && (!($request->user()->principal->isEmpty())) && $request->user()->principal[0]->roles && $request->user()->principal[0]->roles->code === 'PRINCIPAL') { return $next($request); - }elseif($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL'){ + }elseif ($request->user() && (!($request->user()->zonal_cordinator->isEmpty())) && $request->user()->zonal_cordinator[0]->roles && $request->user()->zonal_cordinator[0]->roles->code === 'PRINCIPAL') { return $next($request); } return redirect('/login')->with('status', 'Your dont have access for upload data. Please get assign your to the class and try'); diff --git a/app/Imports/Import.php b/app/Imports/Import.php index 7fc43ef0..3bcd9067 100755 --- a/app/Imports/Import.php +++ b/app/Imports/Import.php @@ -84,10 +84,10 @@ public function limit(): int { $highestColumn = $this->worksheet->getHighestDataColumn(3); $higestRow = 0; for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); if (isEmptyRow(reset($rowData))) { continue; - } else { + }else { $higestRow += 1; } } @@ -96,13 +96,13 @@ public function limit(): int { public function validateColumns($column) { $columns = Config::get('excel.columns'); - if ( ($column !== "") && (!in_array($column,$columns))) { + if (($column !== "") && (!in_array($column, $columns))) { $this->isValidSheet = false; $error = \Illuminate\Validation\ValidationException::withMessages([]); - $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); - $failures = [0 => $failure]; - throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); + $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); + $failures = [0 => $failure]; + throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); } } @@ -111,16 +111,16 @@ public function batchSize(): int { $highestColumn = $this->worksheet->getHighestDataColumn(3); $higestRow = 1; for ($row = $this->startRow(); $row <= $this->highestRow; $row++) { - $rowData = $this->worksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); + $rowData = $this->worksheet->rangeToArray('A'.$row.':'.$highestColumn.$row, NULL, TRUE, FALSE); if (isEmptyRow(reset($rowData))) { continue; - } else { + }else { $higestRow += 1; } } if ($higestRow == 0) { exit; - } else { + }else { return $higestRow; } } @@ -135,22 +135,22 @@ public function headingRow(): int { } - protected function formateDate($row,$column,$format = 'Y-m-d'){ + protected function formateDate($row, $column, $format = 'Y-m-d') { try { - if(!empty($row[$column]) && ($row[$column] !== null)){ - switch (gettype($row[$column])){ + if (!empty($row[$column]) && ($row[$column] !== null)) { + switch (gettype($row[$column])) { case 'string': $row[$column] = preg_replace('/[^A-Za-z0-9\-]/', '-', $row[$column]); $row[$column] = date($format, strtotime($row[$column])); //date($row[$column]); - $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); + $row[$column] = \Carbon\Carbon::createFromFormat($format, $row[$column]); break; case 'double'; - $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); + $row[$column] = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[$column]); break; } } return $row; - }catch (Exception $e){ + }catch (Exception $e) { $error = \Illuminate\Validation\ValidationException::withMessages([]); $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); $failures = [0 => $failure]; @@ -160,32 +160,32 @@ protected function formateDate($row,$column,$format = 'Y-m-d'){ } - protected function mapFields($row){ + protected function mapFields($row) { $keys = array_keys($row); - array_walk($keys,array($this,'validateColumns')); - $row = $this->formateDate($row,'date_of_birth_yyyy_mm_dd'); - $row = $this->formateDate($row,'bmi_date_yyyy_mm_dd'); - $row = $this->formateDate($row,'start_date_yyyy_mm_dd'); - $row = $this->formateDate($row,'fathers_date_of_birth_yyyy_mm_dd'); - $row = $this->formateDate($row,'mothers_date_of_birth_yyyy_mm_dd'); - $row = $this->formateDate($row,'guardians_date_of_birth_yyyy_mm_dd'); + array_walk($keys, array($this, 'validateColumns')); + $row = $this->formateDate($row, 'date_of_birth_yyyy_mm_dd'); + $row = $this->formateDate($row, 'bmi_date_yyyy_mm_dd'); + $row = $this->formateDate($row, 'start_date_yyyy_mm_dd'); + $row = $this->formateDate($row, 'fathers_date_of_birth_yyyy_mm_dd'); + $row = $this->formateDate($row, 'mothers_date_of_birth_yyyy_mm_dd'); + $row = $this->formateDate($row, 'guardians_date_of_birth_yyyy_mm_dd'); $columns = Config::get('excel.columns'); - if(!$this->template) { + if (!$this->template) { array_walk($columns, array($this, 'checkKeys'), $row); $this->template = true; } - $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); + $row['admission_no'] = str_pad($row['admission_no'], 4, '0', STR_PAD_LEFT); if ($row['identity_type'] == 'BC' && (!empty($row['birth_divisional_secretariat'])) && ($row['identity_number'] !== null) && $row['date_of_birth_yyyy_mm_dd'] !== null) { - $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); + $row['identity_number'] = str_pad($row['identity_number'], 4, '0', STR_PAD_LEFT); // dd(($row['date_of_birth_yyyy_mm_dd'])); - $BirthDivision = Area_administrative::where('name', 'like', '%' . $row['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5)->first(); + $BirthDivision = Area_administrative::where('name', 'like', '%'.$row['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5)->first(); if ($BirthDivision !== null) { - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%') + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%') ->where('parent_id', '=', $BirthDivision->id)->first(); if ($BirthArea !== null) { - $row['identity_number'] = $BirthArea->id . '' . $row['identity_number'] . '' . substr($row['date_of_birth_yyyy_mm_dd']->format("yy"), -2) . '' . $row['date_of_birth_yyyy_mm_dd']->format("m"); + $row['identity_number'] = $BirthArea->id.''.$row['identity_number'].''.substr($row['date_of_birth_yyyy_mm_dd']->format("yy"), -2).''.$row['date_of_birth_yyyy_mm_dd']->format("m"); } } } @@ -194,9 +194,9 @@ protected function mapFields($row){ } protected function checkKeys($key,$count,$row){ - if(array_key_exists($key,$row)){ - return true; - }else{ + if(array_key_exists($key,$row)){ + return true; + }else{ $error = \Illuminate\Validation\ValidationException::withMessages([]); $failure = new Failure($count, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'. $key ,' Is missing form the template'], [null]); $failures = [0 => $failure]; @@ -216,7 +216,7 @@ public function array(array $array) { */ public function map($row): array { try { - $row = $this->mapFields($row); + $row = $this->mapFields($row); } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { $error = \Illuminate\Validation\ValidationException::withMessages([]); $failure = new Failure(3, 'remark', [0 => 'Template is not valid for upload, use the template given in the system'], [null]); @@ -239,19 +239,19 @@ public function validateClass() { if ($exceededStudents == true) { try { $error = \Illuminate\Validation\ValidationException::withMessages([]); - $failure = new Failure(3, 'remark', [3 => 'Class student count exceeded! Max number of students is' . $institutionClass->no_of_students], [null]); + $failure = new Failure(3, 'remark', [3 => 'Class student count exceeded! Max number of students is'.$institutionClass->no_of_students], [null]); $failures = [0 => $failure]; throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); Log::info('email-sent', [$this->file]); - } catch (Exception $e) { + }catch (Exception $e) { Log::info('email-sending-failed', [$e]); } - } else { + }else { return true; } } - public function getNode(){ + public function getNode() { return $this->file['node']; } @@ -305,7 +305,7 @@ protected function updateSubjectCount($subject) { /** * */ - protected function setStudentSubjects($subject){ + protected function setStudentSubjects($subject) { return [ 'id' => (string) Uuid::generate(4), 'student_id' => $this->student->student_id, @@ -321,8 +321,8 @@ protected function setStudentSubjects($subject){ ]; } - protected function insertSubject($subject){ - if(!Institution_subject_student::isDuplicated($subject)){ + protected function insertSubject($subject) { + if (!Institution_subject_student::isDuplicated($subject)) { Institution_subject_student::updateOrInsert($subject); } } diff --git a/app/Imports/StudentImport.php b/app/Imports/StudentImport.php index 867125c9..91b674d1 100755 --- a/app/Imports/StudentImport.php +++ b/app/Imports/StudentImport.php @@ -18,10 +18,10 @@ public function __construct() } /** - * @param array $row - * - * @return \Illuminate\Database\Eloquent\Model|null - */ + * @param array $row + * + * @return \Illuminate\Database\Eloquent\Model|null + */ public function sheets(): array { @@ -40,7 +40,7 @@ public function registerEvents(): array // TODO: Implement registerEvents() method. return [ - BeforeSheet::class => function(BeforeSheet $event){ + BeforeSheet::class => function(BeforeSheet $event) { $this->sheetNames[] = $event->getSheet()->getTitle(); } diff --git a/app/Imports/StudentUpdate.php b/app/Imports/StudentUpdate.php index 634c94d1..4603d88e 100755 --- a/app/Imports/StudentUpdate.php +++ b/app/Imports/StudentUpdate.php @@ -57,7 +57,7 @@ use Webpatser\Uuid\Uuid; use Mohamednizar\MoeUuid\MoeUuid; -class StudentUpdate extends Import implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation , SkipsOnFailure , SkipsOnError{ +class StudentUpdate extends Import implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation, SkipsOnFailure, SkipsOnError{ use Importable, RegistersEventListeners, @@ -81,7 +81,7 @@ public function registerEvents(): array { $worksheet = $event->getSheet(); $this->highestRow = $worksheet->getHighestDataRow('B'); }, - BeforeImport::class => function (BeforeImport $event) { + BeforeImport::class => function(BeforeImport $event) { $event->getReader()->getDelegate()->setActiveSheetIndex(2); $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('B')); if ($this->highestRow < 3) { @@ -110,7 +110,7 @@ public function model(array $row) { $mandatorySubject = Institution_class_subject::getMandetorySubjects($this->file['institution_class_id']); $subjects = getMatchingKeys($row); $genderId = null; - if($row['gender_mf'] !== null){ + if ($row['gender_mf'] !== null) { $genderId = $row['gender_mf'] == 'M' ? 1 : 2; } switch ($row['gender_mf']) { @@ -122,9 +122,9 @@ public function model(array $row) { break; } - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first(); @@ -193,17 +193,17 @@ public function model(array $row) { if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) { // convert Meeter to CM - $hight = $row['bmi_height'] / 100; + $hight = $row['bmi_height']/100; //calculate BMI - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); - $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id ) - ->where('security_user_id','=',$student->student_id)->count(); + $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id) + ->where('security_user_id', '=', $student->student_id)->count(); \Log::debug('User_body_mass'); - if(!($count > 0)){ + if (!($count > 0)) { User_body_mass::create([ 'height' => $row['bmi_height'], 'weight' => $row['bmi_weight'], @@ -217,9 +217,9 @@ public function model(array $row) { } if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); $openemisFather = MoeUuid::getUniqueAlphanumeric(4); $identityType = ($identityType !== null) ? $identityType->id : null; @@ -235,7 +235,7 @@ public function model(array $row) { if ($father === null) { $father = Security_user::create([ - 'username' => str_replace('-','',$openemisFather), + 'username' => str_replace('-', '', $openemisFather), 'openemis_no' => $openemisFather, 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['fathers_full_name']), @@ -253,25 +253,25 @@ public function model(array $row) { $father['guardian_relation_id'] = 1; if (array_key_exists('fathers_phone', $row)) { $father['contact'] = $row['fathers_phone']; - User_contact::createOrUpdate($father,$this->file['security_user_id']); + User_contact::createOrUpdate($father, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); - } else { + }else { Security_user::where('id', '=', $father->id) ->update(['is_guardian' => 1]); $father['guardian_relation_id'] = 1; if (array_key_exists('fathers_phone', $row)) { $father['contact'] = $row['fathers_phone']; - User_contact::createOrUpdate($father,$this->file['security_user_id']); + User_contact::createOrUpdate($father, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); } } if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); $openemisMother = MoeUuid::getUniqueAlphanumeric(4); $identityType = $identityType !== null ? $identityType->id : null; @@ -286,7 +286,7 @@ public function model(array $row) { if ($mother === null) { $mother = Security_user::create([ - 'username' => str_replace('-','',$openemisMother), + 'username' => str_replace('-', '', $openemisMother), 'openemis_no' => $openemisMother, 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['mothers_full_name']), @@ -304,16 +304,16 @@ public function model(array $row) { $mother['guardian_relation_id'] = 2; if (array_key_exists('mothers_phone', $row)) { $mother['contact'] = $row['mothers_phone']; - User_contact::createOrUpdate($mother,$this->file['security_user_id']); + User_contact::createOrUpdate($mother, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); - } else { + }else { Security_user::where('id', '=', $mother->id) ->update(['is_guardian' => 1]); $mother['guardian_relation_id'] = 2; if (array_key_exists('mothers_phone', $row)) { $mother['contact'] = $row['mothers_phone']; - User_contact::createOrUpdate($mother,$this->file['security_user_id']); + User_contact::createOrUpdate($mother, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); } @@ -322,9 +322,9 @@ public function model(array $row) { if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); $openemisGuardian = MoeUuid::getUniqueAlphanumeric(4); $identityType = $identityType !== null ? $identityType->id : null; @@ -339,7 +339,7 @@ public function model(array $row) { if ($guardian === null) { $guardian = Security_user::create([ - 'username' => str_replace('-','',$openemisGuardian), + 'username' => str_replace('-', '', $openemisGuardian), 'openemis_no' => $openemisGuardian, 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['guardians_full_name']), @@ -358,22 +358,22 @@ public function model(array $row) { $guardian['guardian_relation_id'] = 3; if (array_key_exists('guardians_phone', $row)) { $guardian['contact'] = $row['guardians_phone']; - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); - } else { + }else { Security_user::where('id', '=', $guardian->id) ->update(['is_guardian' => 1]); $guardian['guardian_relation_id'] = 3; if (array_key_exists('guardians_phone', $row)) { $guardian['contact'] = $row['guardians_phone']; - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); } } - $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); + $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject); // $stundetSubjects = $this->getStudentSubjects($student); @@ -382,10 +382,10 @@ public function model(array $row) { if (!empty($allSubjects)) { $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); $this->student = $student; - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); // $allSubjects = array_unique($allSubjects,SORT_REGULAR); $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); - array_walk($allSubjects,array($this,'insertSubject')); + array_walk($allSubjects, array($this, 'insertSubject')); // Institution_subject_student::insert((array) $allSubjects); // array_walk($allSubjects, array($this, 'updateSubjectCount')); } @@ -396,7 +396,7 @@ public function model(array $row) { if ($totalStudents['total'] > $institutionClass->no_of_students) { $error = \Illuminate\Validation\ValidationException::withMessages([]); - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); $failures = [0 => $failure]; throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); Log::info('email-sent', [$this->file]); @@ -408,7 +408,7 @@ public function model(array $row) { 'total_male_students' => $totalStudents['total_male_students'], 'total_female_students' => $totalStudents['total_female_students']]); } - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { $error = \Illuminate\Validation\ValidationException::withMessages([]); $failures = $e->failures(); throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); @@ -422,8 +422,8 @@ public function getStudentSubjects($student) { ->where('institution_class_id', '=', $student->institution_class_id)->get()->toArray(); } - protected function insertSubject($subject){ - if(!Institution_subject_student::isDuplicated($subject)) + protected function insertSubject($subject) { + if (!Institution_subject_student::isDuplicated($subject)) Institution_subject_student::updateOrInsert($subject); } @@ -452,7 +452,7 @@ public function rules(): array { '*.admission_no' => 'nullable|max:12|min:4', '*.start_date_yyyy_mm_dd' => 'nullable|date', '*.special_need_type' => 'nullable', - '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able',//|exists:special_need_difficulties,name + '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able', //|exists:special_need_difficulties,name '*.fathers_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u', '*.fathers_date_of_birth_yyyy_mm_dd' => 'nullable|required_with:*.fathers_full_name', '*.fathers_address' => 'required_with:*.fathers_full_name', diff --git a/app/Imports/UsersImport.php b/app/Imports/UsersImport.php index 15cd26a7..b9d08bac 100755 --- a/app/Imports/UsersImport.php +++ b/app/Imports/UsersImport.php @@ -60,9 +60,9 @@ use Maatwebsite\Excel\Exceptions\ConcernConflictException; use Mohamednizar\MoeUuid\MoeUuid; -class UsersImport extends Import Implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation ,SkipsOnFailure ,SkipsOnError { +class UsersImport extends Import Implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation, SkipsOnFailure, SkipsOnError { - use Importable, SkipsFailures , SkipsErrors; + use Importable, SkipsFailures, SkipsErrors; public function sheets(): array { @@ -86,7 +86,7 @@ public function registerEvents(): array { throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); } }, - BeforeImport::class => function (BeforeImport $event) { + BeforeImport::class => function(BeforeImport $event) { $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('C')); if ($this->highestRow < 3) { $error = \Illuminate\Validation\ValidationException::withMessages([]); @@ -122,9 +122,9 @@ public function model(array $row) { break; } - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first(); @@ -140,8 +140,8 @@ public function model(array $row) { $openemisStudent = MoeUuid::getUniqueAlphanumeric(3); \Log::debug('Security_user'); - $student = Security_user::create([ - 'username' => str_replace('-','',$openemisStudent), + $student = Security_user::create([ + 'username' => str_replace('-', '', $openemisStudent), 'openemis_no' => $openemisStudent, 'first_name' => $row['full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['full_name']), @@ -234,12 +234,12 @@ public function model(array $row) { } - if(!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])){ + if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) { // convert Meeter to CM - $hight = $row['bmi_height'] / 100; + $hight = $row['bmi_height']/100; //calculate BMI - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); @@ -258,9 +258,9 @@ public function model(array $row) { if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); $openemisFather = MoeUuid::getUniqueAlphanumeric(4); $identityType = ($identityType !== null) ? $identityType->id : null; @@ -276,7 +276,7 @@ public function model(array $row) { if ($father === null) { $father = Security_user::create([ - 'username' => str_replace('-','',$openemisFather), + 'username' => str_replace('-', '', $openemisFather), 'openemis_no' => $openemisFather, 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['fathers_full_name']), @@ -295,25 +295,25 @@ public function model(array $row) { $father['guardian_relation_id'] = 1; if (array_key_exists('fathers_phone', $row)) { $father['contact'] = $row['fathers_phone']; - User_contact::createOrUpdate($father,$this->file['security_user_id']); + User_contact::createOrUpdate($father, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); - } else { + }else { Security_user::where('id', '=', $father->id) ->update(['is_guardian' => 1]); $father['guardian_relation_id'] = 1; if (array_key_exists('fathers_phone', $row)) { $father['contact'] = $row['fathers_phone']; - User_contact::createOrUpdate($father,$this->file['security_user_id']); + User_contact::createOrUpdate($father, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); } } if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); $openemisMother = MoeUuid::getUniqueAlphanumeric(4); $identityType = $identityType !== null ? $identityType->id : null; @@ -328,7 +328,7 @@ public function model(array $row) { if ($mother === null) { $mother = Security_user::create([ - 'username' => str_replace('-','',$openemisMother), + 'username' => str_replace('-', '', $openemisMother), 'openemis_no' => $openemisMother, 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['mothers_full_name']), @@ -355,16 +355,16 @@ public function model(array $row) { $mother['guardian_relation_id'] = 2; if (array_key_exists('mothers_phone', $row)) { $mother['contact'] = $row['mothers_phone']; - User_contact::createOrUpdate($mother,$this->file['security_user_id']); + User_contact::createOrUpdate($mother, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); - } else { + }else { Security_user::where('id', '=', $mother->id) ->update(['is_guardian' => 1]); $mother['guardian_relation_id'] = 2; if (array_key_exists('mothers_phone', $row)) { $mother['contact'] = $row['mothers_phone']; - User_contact::createOrUpdate($mother,$this->file['security_user_id']); + User_contact::createOrUpdate($mother, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); } @@ -373,9 +373,9 @@ public function model(array $row) { if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); $openemisGuardian = MoeUuid::getUniqueAlphanumeric(4); $identityType = $identityType !== null ? $identityType->id : null; @@ -390,7 +390,7 @@ public function model(array $row) { if ($guardian === null) { $guardian = Security_user::create([ - 'username' => str_replace('-','',$openemisGuardian), + 'username' => str_replace('-', '', $openemisGuardian), 'openemis_no' => $openemisGuardian, 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. 'last_name' => genNameWithInitials($row['guardians_full_name']), @@ -417,16 +417,16 @@ public function model(array $row) { $guardian['guardian_relation_id'] = 3; if (array_key_exists('guardians_phone', $row)) { $guardian['contact'] = $row['guardians_phone']; - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); - } else { + }else { Security_user::where('id', '=', $guardian->id) ->update(['is_guardian' => 1]); $guardian['guardian_relation_id'] = 3; if (array_key_exists('guardians_phone', $row)) { $guardian['contact'] = $row['guardians_phone']; - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); } Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); } @@ -439,12 +439,12 @@ public function model(array $row) { if (!empty($allSubjects)) { $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); $this->student = $student; - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); // $allSubjects = array_unique($allSubjects,SORT_REGULAR); // $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); // array_walk($allSubjects,array($this,'insertSubject')); $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); - array_walk($allSubjects,array($this,'insertSubject')); + array_walk($allSubjects, array($this, 'insertSubject')); // Institution_subject_student::insert((array) $allSubjects); } @@ -454,7 +454,7 @@ public function model(array $row) { if ($totalStudents['total'] > $institutionClass->no_of_students) { $error = \Illuminate\Validation\ValidationException::withMessages([]); - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); $failures = [0 => $failure]; throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); Log::info('email-sent', [$this->file]); @@ -465,7 +465,7 @@ public function model(array $row) { 'total_male_students' => $totalStudents['total_male_students'], 'total_female_students' => $totalStudents['total_female_students']]); } - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { $error = \Illuminate\Validation\ValidationException::withMessages([]); // $failure = new Failure(3, 'remark', [3 => ], [null]); $failures = $e->failures(); @@ -479,7 +479,7 @@ public function rules(): array { return [ '*.full_name' => 'required|regex:/^[\pL\s\-]+$/u|max:100', '*.gender_mf' => 'required|in:M,F', - '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'], + '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'], '*.address' => 'nullable', '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place', '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate', @@ -489,14 +489,14 @@ public function rules(): array { '*.academic_period' => 'required|exists:academic_periods,name', '*.education_grade' => 'required', '*.option_*' => 'nullable|exists:education_subjects,name', - '*.bmi_height' => 'bail|bmi:'. $this->file['institution_class_id'], - '*.bmi_weight' => 'bail|bmi:'. $this->file['institution_class_id'], - '*.bmi_date_yyyy_mm_dd' => 'bail|bmi:'. $this->file['institution_class_id'].'date', - '*.bmi_academic_period' => 'bail|bmi:'. $this->file['institution_class_id'].'exists:academic_periods,name', + '*.bmi_height' => 'bail|bmi:'.$this->file['institution_class_id'], + '*.bmi_weight' => 'bail|bmi:'.$this->file['institution_class_id'], + '*.bmi_date_yyyy_mm_dd' => 'bail|bmi:'.$this->file['institution_class_id'].'date', + '*.bmi_academic_period' => 'bail|bmi:'.$this->file['institution_class_id'].'exists:academic_periods,name', '*.admission_no' => 'required|max:12|min:1', '*.start_date_yyyy_mm_dd' => 'required', '*.special_need_type' => 'nullable', - '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able',//|exists:special_need_difficulties,name', + '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able', //|exists:special_need_difficulties,name', '*.fathers_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u', '*.fathers_date_of_birth_yyyy_mm_dd' => 'required_with:fathers_full_name', '*.fathers_address' => 'required_with:fathers_full_name', diff --git a/app/Libraries/ShaHash/SHAHasher.php b/app/Libraries/ShaHash/SHAHasher.php index befbc041..8dbb0310 100755 --- a/app/Libraries/ShaHash/SHAHasher.php +++ b/app/Libraries/ShaHash/SHAHasher.php @@ -13,13 +13,13 @@ class SHAHasher extends HashManager implements HasherContract public function check($value, $hashedValue, array $options = []) { - return password_verify ($value , $hashedValue); + return password_verify($value, $hashedValue); } public function make($value, array $options = []) { - return password_hash($value,PASSWORD_DEFAULT,$options); + return password_hash($value, PASSWORD_DEFAULT, $options); } @@ -27,7 +27,7 @@ public function make($value, array $options = []) public function needsRehash($hashedValue, array $options = []) { - return password_needs_rehash($hashedValue,$options); + return password_needs_rehash($hashedValue, $options); } diff --git a/app/Mail/EmptyFile.php b/app/Mail/EmptyFile.php index a653cb50..7d21b25f 100755 --- a/app/Mail/EmptyFile.php +++ b/app/Mail/EmptyFile.php @@ -25,7 +25,7 @@ public function __construct($file) $this->user = User::find($file['security_user_id']); - $this->subject = 'SIS Bulk Upload: ' .$file['subject'].' Empty ' . $institution->institution->code.': '. $institution->name.' '. date('Y:m:d H:i:s'); + $this->subject = 'SIS Bulk Upload: '.$file['subject'].' Empty '.$institution->institution->code.': '.$institution->name.' '.date('Y:m:d H:i:s'); $this->from_address = env('MAIL_FROM_ADDRESS'); $this->from_name = 'SIS Bulk Uploader'; $this->with = [ @@ -33,7 +33,7 @@ public function __construct($file) 'link' => env('APP_URL').'bulk-upload/' ]; $this->viewData = [ - 'name'=>$this->user->first_name, "body" => "No data Found in ". $file['filename']. ' Please re-upload the file with data', + 'name'=>$this->user->first_name, "body" => "No data Found in ".$file['filename'].' Please re-upload the file with data', 'link' => env('APP_URL').'bulk-upload/' ]; } @@ -46,7 +46,7 @@ public function __construct($file) public function build() { return $this->view('emails.mail') - ->from($this->from_address,$this->from_name) + ->from($this->from_address, $this->from_name) ->to($this->user->email) ->subject($this->subject) ->with($this->with); diff --git a/app/Mail/IncorrectTemplate.php b/app/Mail/IncorrectTemplate.php index ec1c19d1..2a965142 100755 --- a/app/Mail/IncorrectTemplate.php +++ b/app/Mail/IncorrectTemplate.php @@ -11,11 +11,11 @@ class IncorrectTemplate extends Mailable { use Queueable, SerializesModels; - /** - * Create a new message instance. - * - * @return void - */ + /** + * Create a new message instance. + * + * @return void + */ public function __construct($file) { @@ -23,15 +23,15 @@ public function __construct($file) $this->user = User::find($file['security_user_id']); - $this->subject = 'SIS Bulk Upload: IncorrectTemplate'.$institution->institution->code.': '. $institution->name.' '. date('Y:m:d H:i:s'); + $this->subject = 'SIS Bulk Upload: IncorrectTemplate'.$institution->institution->code.': '.$institution->name.' '.date('Y:m:d H:i:s'); $this->from_address = env('MAIL_FROM_ADDRESS'); $this->from_name = 'SIS Bulk Uploader'; $this->with = [ 'name' => $this->user->first_name, - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] $this->viewData = [ 'name'=>$this->user->first_name, "body" => "The Template you used for upload having some issues, please reconfirm and re-upload with correct template", - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; } @@ -43,7 +43,7 @@ public function __construct($file) public function build() { return $this->view('emails.mail') - ->from($this->from_address,$this->from_name) + ->from($this->from_address, $this->from_name) ->to($this->user->email) ->subject($this->subject) ->with($this->with); diff --git a/app/Mail/StudentCountExceeded.php b/app/Mail/StudentCountExceeded.php index 4e393723..fdd60710 100755 --- a/app/Mail/StudentCountExceeded.php +++ b/app/Mail/StudentCountExceeded.php @@ -31,16 +31,16 @@ public function __construct($file) $institution = Institution_class::find($file['institution_class_id']); $this->user = User::find($file['security_user_id']); - $this->subject = 'SIS Bulk Upload: Upload Failed '.$institution->institution->code.': '. $institution->name . date('Y:m:d H:i:s'); + $this->subject = 'SIS Bulk Upload: Upload Failed '.$institution->institution->code.': '.$institution->name.date('Y:m:d H:i:s'); $this->from_address = env('MAIL_FROM_ADDRESS'); $this->from_name = 'SIS Bulk Uploader'; $this->with = [ 'name' => $this->user->first_name, - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; $this->viewData = [ 'name'=>$this->user->first_name, "body" => "The class you tried to import data is exceeded the student count limit.Please check the class / increase the student limit", - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; } @@ -52,7 +52,7 @@ public function __construct($file) public function build() { return $this->view('emails.mail') - ->from($this->from_address,$this->from_name) + ->from($this->from_address, $this->from_name) ->to($this->user->email) ->subject($this->subject) ->with($this->with); diff --git a/app/Mail/StudentImportFailure.php b/app/Mail/StudentImportFailure.php index ede3715e..4be1ee45 100755 --- a/app/Mail/StudentImportFailure.php +++ b/app/Mail/StudentImportFailure.php @@ -24,17 +24,17 @@ public function __construct($file) $this->user = User::find($file['security_user_id']); - $this->subject = 'SIS Bulk Upload: ' .$file['subject']. $institution->institution->code.': '. $institution->name.' '. date('Y:m:d H:i:s'); + $this->subject = 'SIS Bulk Upload: '.$file['subject'].$institution->institution->code.': '.$institution->name.' '.date('Y:m:d H:i:s'); $this->from_address = env('MAIL_FROM_ADDRESS'); $this->from_name = 'SIS Bulk Uploader'; $this->with = [ 'name' => $this->user->first_name, - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; $this->viewData = [ - 'name'=>$this->user->first_name, "body" => "We found some errors on your data file ". $file['filename']. ' Pleas fix the errors and re-upload only with incorrect data, + 'name'=>$this->user->first_name, "body" => "We found some errors on your data file ".$file['filename'].' Pleas fix the errors and re-upload only with incorrect data, We uploaded the correct data to the system', - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; } @@ -46,7 +46,7 @@ public function __construct($file) public function build() { return $this->view('emails.mail') - ->from($this->from_address,$this->from_name) + ->from($this->from_address, $this->from_name) ->to($this->user->email) ->subject($this->subject) ->with($this->with); diff --git a/app/Mail/StudentImportSuccess.php b/app/Mail/StudentImportSuccess.php index 58e0fc1d..5aaeedd5 100755 --- a/app/Mail/StudentImportSuccess.php +++ b/app/Mail/StudentImportSuccess.php @@ -24,7 +24,7 @@ public function __construct($file) $institution = Institution_class::find($file['institution_class_id']); $this->user = User::find($file['security_user_id']); - $this->subject = 'SIS Bulk upload: '. $file['subject'] .$institution->institution->code.': '. $institution->name.' ' . date('Y:m:d H:i:s'); + $this->subject = 'SIS Bulk upload: '.$file['subject'].$institution->institution->code.': '.$institution->name.' '.date('Y:m:d H:i:s'); $this->from_address = env('MAIL_FROM_ADDRESS'); $this->from_name = 'SIS Bulk Uploader'; $this->with = [ @@ -45,8 +45,8 @@ public function __construct($file) public function build() { return $this->view('emails.mail') - ->from($this->from_address,$this->from_name) - ->to($this->user->email) + ->from($this->from_address,$this->from_name) + ->to($this->user->email) ->subject($this->subject) ->with($this->with); } diff --git a/app/Mail/TerminatedReport.php b/app/Mail/TerminatedReport.php index cb0db994..a15bbbe4 100755 --- a/app/Mail/TerminatedReport.php +++ b/app/Mail/TerminatedReport.php @@ -22,17 +22,17 @@ public function __construct($file) $institution = Institution_class::find($file['institution_class_id']); $this->user = User::find($file['security_user_id']); - $this->subject = 'SIS Bulk Upload: Process Terminated'.$institution->institution->code.': '. $institution->name.' '. date('Y:m:d H:i:s'); + $this->subject = 'SIS Bulk Upload: Process Terminated'.$institution->institution->code.': '.$institution->name.' '.date('Y:m:d H:i:s'); $this->from_address = env('MAIL_FROM_ADDRESS'); $this->from_name = 'SIS Bulk Uploader'; $this->with = [ 'name' => $this->user->first_name, - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; $this->viewData = [ 'name'=>$this->user->first_name, "body" => "Apologize ,The process of you file has been terminated in the middle, We advice you to check the student data and re-upload with only with correct data which are not in the system ", - 'link' => env('APP_URL').'/download/' .$file['filename'] + 'link' => env('APP_URL').'/download/'.$file['filename'] ]; } @@ -44,7 +44,7 @@ public function __construct($file) public function build() { return $this->view('emails.mail') - ->from($this->from_address,$this->from_name) + ->from($this->from_address, $this->from_name) ->to($this->user->email) ->subject($this->subject) ->with($this->with); diff --git a/app/Models/Academic_period.php b/app/Models/Academic_period.php index e3f7c679..d7bd7e6d 100755 --- a/app/Models/Academic_period.php +++ b/app/Models/Academic_period.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Academic_period extends Base_Model { +class Academic_period extends Base_Model { /** * The database table used by the model. @@ -41,8 +41,8 @@ class Academic_period extends Base_Model { */ protected $dates = ['start_date', 'end_date', 'modified', 'created']; - public function getAcademicPeriod($year){ - return self::query()->where('code',$year)->first(); + public function getAcademicPeriod($year) { + return self::query()->where('code', $year)->first(); } } diff --git a/app/Models/Area.php b/app/Models/Area.php index e11c80bc..75d20ffa 100755 --- a/app/Models/Area.php +++ b/app/Models/Area.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Area extends Model { +class Area extends Model { /** * The database table used by the model. diff --git a/app/Models/Area_administrative.php b/app/Models/Area_administrative.php index 569d2718..68c8bb3e 100755 --- a/app/Models/Area_administrative.php +++ b/app/Models/Area_administrative.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Area_administrative extends Model { +class Area_administrative extends Model { /** * The database table used by the model. diff --git a/app/Models/Base_Model.php b/app/Models/Base_Model.php index 7227154d..de162154 100755 --- a/app/Models/Base_Model.php +++ b/app/Models/Base_Model.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Auth; -class Base_Model extends Model{ +class Base_Model extends Model { @@ -18,10 +18,10 @@ public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->created = Carbon::now(); }); - self::updating(function ($model) { + self::updating(function($model) { $model->modified = Carbon::now(); }); } diff --git a/app/Models/Education_grade.php b/app/Models/Education_grade.php index 291847db..589183ea 100755 --- a/app/Models/Education_grade.php +++ b/app/Models/Education_grade.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Education_grade extends Model { +class Education_grade extends Model { /** * The database table used by the model. @@ -41,17 +41,17 @@ class Education_grade extends Model { */ protected $dates = ['modified', 'created']; - public function getNextGrade($gradeId,$getNextProgrammeGrades = false, $firstGradeOnly = false){ + public function getNextGrade($gradeId, $getNextProgrammeGrades = false, $firstGradeOnly = false) { if (!empty($gradeId)) { $gradeObj = $this->find($gradeId); $programmeId = $gradeObj->education_programme_id; $order = $gradeObj->order; - $gradeOptions = self::where( 'education_programme_id',$programmeId - )->where('order',$order+1)->get()->first(); + $gradeOptions = self::where('education_programme_id', $programmeId + )->where('order', $order + 1)->get()->first(); $nextProgramme = self::getNextProgrammeList($programmeId); - if(empty($gradeOptions) && !is_null($nextProgramme)){ + if (empty($gradeOptions) && !is_null($nextProgramme)) { $programmeId = $nextProgramme->next_programme_id; - $gradeOptions = self::where( 'education_programme_id',$programmeId + $gradeOptions = self::where('education_programme_id', $programmeId )->get()->first(); } // Default is to get the list of grades with the next programme grades @@ -66,7 +66,7 @@ public function getNextGrade($gradeId,$getNextProgrammeGrades = false, $firstGra // $results = $gradeOptions; // } return $gradeOptions; - } else { + }else { return null; } } @@ -78,11 +78,11 @@ public function getNextProgrammeFirstGradeList($id) { foreach ($nextProgrammeList as $nextProgrammeId) { $nextProgrammeGradeResults = self:: - where('education_programme_id',$nextProgrammeId->next_programme_id)->get()->toArray(); + where('education_programme_id', $nextProgrammeId->next_programme_id)->get()->toArray(); $results = $results + [key($nextProgrammeGradeResults) => current($nextProgrammeGradeResults)]; } - } else { + }else { $results = []; } @@ -100,9 +100,9 @@ public function getNextGradeList($id) { $nextProgrammeList = $this->getNextProgrammeList($id); if (!empty($nextProgrammeList)) { - $results = self::whereIn('education_programme_id',$nextProgrammeList) + $results = self::whereIn('education_programme_id', $nextProgrammeList) ->get()->toArray(); - } else { + }else { $results = []; } @@ -116,7 +116,7 @@ public function getNextGradeList($id) { * @return array List of next education programmes id */ public function getNextProgrammeList($id) { - return Education_programmes_next_programme::where('education_programme_id',$id) + return Education_programmes_next_programme::where('education_programme_id', $id) ->get()->first(); } diff --git a/app/Models/Education_grades_subject.php b/app/Models/Education_grades_subject.php index 4cc51b5f..4b41abdb 100755 --- a/app/Models/Education_grades_subject.php +++ b/app/Models/Education_grades_subject.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Education_grades_subject extends Model { +class Education_grades_subject extends Model { /** * The database table used by the model. @@ -42,8 +42,8 @@ class Education_grades_subject extends Model { protected $dates = ['modified', 'created']; - public function institutionGradeSubject(){ - return $this->hasMany('App\Models\Institution_subject','education_grade_id','education_grade_id'); + public function institutionGradeSubject() { + return $this->hasMany('App\Models\Institution_subject', 'education_grade_id', 'education_grade_id'); } diff --git a/app/Models/Education_programmes_next_programme.php b/app/Models/Education_programmes_next_programme.php index 483f0eb2..7780844c 100755 --- a/app/Models/Education_programmes_next_programme.php +++ b/app/Models/Education_programmes_next_programme.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; -class Education_programmes_next_programme extends Model { +class Education_programmes_next_programme extends Model { /** * The database table used by the model. diff --git a/app/Models/Identity_type.php b/app/Models/Identity_type.php index 90059141..01ec01ca 100755 --- a/app/Models/Identity_type.php +++ b/app/Models/Identity_type.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Identity_type extends Model { +class Identity_type extends Model { /** * The database table used by the model. diff --git a/app/Models/Import_mapping.php b/app/Models/Import_mapping.php index eb4f7912..2ebb3aab 100755 --- a/app/Models/Import_mapping.php +++ b/app/Models/Import_mapping.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Import_mapping extends Model { +class Import_mapping extends Model { /** * The database table used by the model. @@ -42,7 +42,7 @@ class Import_mapping extends Model { protected $dates = []; - public static function getSheetColumns($model = null){ + public static function getSheetColumns($model = null) { $columns = Import_mapping::where('model', '=', $model) ->orderBy('order') ->get()->toArray(); diff --git a/app/Models/Institution.php b/app/Models/Institution.php index c6dd9266..cab9a9c9 100755 --- a/app/Models/Institution.php +++ b/app/Models/Institution.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution extends Model { +class Institution extends Model { /** * The database table used by the model. @@ -42,7 +42,7 @@ class Institution extends Model { protected $dates = ['date_opened', 'date_closed', 'modified', 'created']; public function isActive($id){ - return self::query()->find($id)->get()->first()->institution_status_id == 1; + return self::query()->find($id)->get()->first()->institution_status_id == 1; } } diff --git a/app/Models/Institution_class.php b/app/Models/Institution_class.php index 2808718c..5d763c8b 100755 --- a/app/Models/Institution_class.php +++ b/app/Models/Institution_class.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution_class extends Base_Model { +class Institution_class extends Base_Model { public const CREATED_AT = 'created'; public const UPDATED_AT = 'modified'; @@ -48,22 +48,22 @@ class Institution_class extends Base_Model { */ protected $dates = ['modified', 'created']; - public function class_teacher(){ - return $this->belongsTo('App\Models\Security_group_user','staff_id','security_user_id'); + public function class_teacher() { + return $this->belongsTo('App\Models\Security_group_user', 'staff_id', 'security_user_id'); } - public function institution(){ - return $this->belongsTo('App\Models\Institution','institution_id'); + public function institution() { + return $this->belongsTo('App\Models\Institution', 'institution_id'); } - public function getShiftClasses($shift){ + public function getShiftClasses($shift) { return self::query() - ->select('institution_classes.id','institution_classes.institution_id','institution_classes.institution_shift_id', - 'institution_classes.name','institution_classes.no_of_students','institution_classes.class_number','institution_class_grades.education_grade_id') - ->where('institution_shift_id',$shift) + ->select('institution_classes.id', 'institution_classes.institution_id', 'institution_classes.institution_shift_id', + 'institution_classes.name', 'institution_classes.no_of_students', 'institution_classes.class_number', 'institution_class_grades.education_grade_id') + ->where('institution_shift_id', $shift) // ->where('academic_period_id',$academicPeriod) - ->join('institution_class_grades','institution_classes.id','institution_class_grades.institution_class_id') + ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id') ->groupBy('institution_classes.id') ->get()->toArray(); } diff --git a/app/Models/Institution_class_grade.php b/app/Models/Institution_class_grade.php index 2cde7bbf..81b8ba68 100755 --- a/app/Models/Institution_class_grade.php +++ b/app/Models/Institution_class_grade.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Webpatser\Uuid\Uuid; -class Institution_class_grade extends Base_Model { +class Institution_class_grade extends Base_Model { /** * The database table used by the model. @@ -46,9 +46,9 @@ class Institution_class_grade extends Base_Model { * * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough */ - public function educationSubject(){ - return $this->hasManyThrough('App\Models\Education_grades_subject','App\Models\Institution_subject', - 'education_subject_id' ,'education_subject_id'); + public function educationSubject() { + return $this->hasManyThrough('App\Models\Education_grades_subject', 'App\Models\Institution_subject', + 'education_subject_id', 'education_subject_id'); } /** @@ -70,7 +70,7 @@ public function getParallelClasses($id, $educationGradeId, $institutionId) public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); }); } @@ -79,7 +79,7 @@ public static function boot() /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function classes(){ - return $this->belongsTo('App\Models\Institution_grade','institution_class_id','id'); + public function classes() { + return $this->belongsTo('App\Models\Institution_grade', 'institution_class_id', 'id'); } } diff --git a/app/Models/Institution_class_student.php b/app/Models/Institution_class_student.php index 6689d14c..2fa8e940 100755 --- a/app/Models/Institution_class_student.php +++ b/app/Models/Institution_class_student.php @@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Auth; use Webpatser\Uuid\Uuid; -class Institution_class_student extends Model { +class Institution_class_student extends Model { /** * The database table used by the model. @@ -51,26 +51,26 @@ class Institution_class_student extends Model { public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); $model->created = now(); }); } - public function student(){ - return $this->belongsTo('App\Models\Security_user','student_id'); + public function student() { + return $this->belongsTo('App\Models\Security_user', 'student_id'); } public static function getStudentsCount($institution_class_id) { $total_male_students = self::with(['student' => function($query) { $query->where('student.gender_id', '=', 1); - }])->whereHas('student', function ($query) { + }])->whereHas('student', function($query) { $query->where('gender_id', '=', 1); })->where('institution_class_id', '=', $institution_class_id)->count(); $total_female_students = self::with(['student' => function($query) { $query->where('student.gender_id', '=', 2); - }])->whereHas('student', function ($query) { + }])->whereHas('student', function($query) { $query->where('gender_id', '=', 2); })->where('institution_class_id', '=', $institution_class_id)->count(); @@ -84,19 +84,19 @@ public static function getStudentsCount($institution_class_id) { ]; } - public static function isDuplicated($inputs){ + public static function isDuplicated($inputs) { - $exists = self::where('student_id','=',$inputs['student_id']) - ->where('institution_class_id',$inputs['institution_class_id']) + $exists = self::where('student_id', '=', $inputs['student_id']) + ->where('institution_class_id', $inputs['institution_class_id']) ->count(); return $exists; } - public function getStudentNewClass($student){ + public function getStudentNewClass($student) { return self::query() - ->where('student_id',$student['student_id']) - ->join('institution_classes','institution_class_students.institution_class_id','=','institution_classes.id') + ->where('student_id', $student['student_id']) + ->join('institution_classes', 'institution_class_students.institution_class_id', '=', 'institution_classes.id') ->where('institution_class_students.student_id', $student['student_id']) ->get()->last(); } diff --git a/app/Models/Institution_class_subject.php b/app/Models/Institution_class_subject.php index 07b2856c..cce871e8 100755 --- a/app/Models/Institution_class_subject.php +++ b/app/Models/Institution_class_subject.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Webpatser\Uuid\Uuid; -class Institution_class_subject extends Base_Model { +class Institution_class_subject extends Base_Model { /** * The database table used by the model. @@ -42,11 +42,11 @@ class Institution_class_subject extends Base_Model { */ protected $dates = ['modified', 'created']; - public function institutionMandatorySubject(){ - return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id') + public function institutionMandatorySubject() { + return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id') ->with('institutionGradeSubject') - ->whereHas('institutionGradeSubject', function ($query) { - $query->where('auto_allocation',1); + ->whereHas('institutionGradeSubject', function($query) { + $query->where('auto_allocation', 1); }); // ->using('App\Models\Institution_subject','institution_subjects.education_subject_id','education_grades_subjects.education_subject_id'); // return $this->belongsToMany('App\Models\Education_grades_subject','institution_subjects','education_subject_id') @@ -59,11 +59,11 @@ public function institutionMandatorySubject(){ // }); } - public function institutionOptionalSubject(){ - return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id') + public function institutionOptionalSubject() { + return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id') ->with('institutionGradeSubject') - ->whereHas('institutionGradeSubject', function ($query) { - $query->where('auto_allocation',0); + ->whereHas('institutionGradeSubject', function($query) { + $query->where('auto_allocation', 0); }); } @@ -71,23 +71,23 @@ public function institutionOptionalSubject(){ public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); }); } - public function institutionSubject(){ - return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id') + public function institutionSubject() { + return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id') ->with('institutionGradeSubject'); } - public static function getMandetorySubjects($institutionClass){ + public static function getMandetorySubjects($institutionClass) { $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass)->first(); $mandatorySubject = Institution_class_subject::with(['institutionSubject']) - ->whereHas('institutionSubject', function ($query) use ($institutionGrade) { - $query->whereHas('institutionGradeSubject',function($query){ - $query->where('auto_allocation',1); + ->whereHas('institutionSubject', function($query) use ($institutionGrade) { + $query->whereHas('institutionGradeSubject', function($query) { + $query->where('auto_allocation', 1); })->where('education_grade_id', $institutionGrade->education_grade_id); // ->where('auto_allocation', $institutionGrade->education_grade_id); }) @@ -100,30 +100,31 @@ public static function getStudentOptionalSubject($subjects, $student, $row, $ins $data = []; foreach ($subjects as $subject) { $subjectId = Institution_class_subject::with(['institutionSubject']) - ->whereHas('institutionSubject', function ($query) use ($row, $subject, $student) { - $query->whereHas('institutionGradeSubject',function($query){ - $query->where('auto_allocation',0); + ->whereHas('institutionSubject', function($query) use ($row, $subject, $student) { + $query->whereHas('institutionGradeSubject', function($query) { + $query->where('auto_allocation', 0); }) ->where('name', '=', $row[$subject]) ->where('education_grade_id', '=', $student->education_grade_id); }) ->where('institution_class_id', '=', $student->institution_class_id) ->get()->toArray(); - if (!empty($subjectId)) - $data[] = $subjectId[0]; + if (!empty($subjectId)) { + $data[] = $subjectId[0]; + } } return $data; } - public function getInstitutionClassSubjects($academicPeriodId,$classIds){ + public function getInstitutionClassSubjects($academicPeriodId, $classIds) { return self::query() - ->whereIn('institution_class_id',$classIds) + ->whereIn('institution_class_id', $classIds) ->get() ->toArray(); } - public function isDuplicated($subject){ - return self::query()->where('institution_subject_id',$subject['institution_subject_id']) - ->where('institution_class_id',$subject['institution_class_id'])->exists(); + public function isDuplicated($subject) { + return self::query()->where('institution_subject_id', $subject['institution_subject_id']) + ->where('institution_class_id', $subject['institution_class_id'])->exists(); } } diff --git a/app/Models/Institution_grade.php b/app/Models/Institution_grade.php index 7076bff9..8775c78f 100755 --- a/app/Models/Institution_grade.php +++ b/app/Models/Institution_grade.php @@ -71,11 +71,11 @@ public function getParallelClasses($id, $institutionId, $educationGradeId, $acad { if (!is_null($id)) { return self::find($id) - ->select('institution_grades.id as insGrade','institution_classes.id', 'institution_classes.name', 'institution_grades.education_grade_id') - ->join('institution_classes', function ($join) use ($educationGradeId, $academicPeriodId) { + ->select('institution_grades.id as insGrade', 'institution_classes.id', 'institution_classes.name', 'institution_grades.education_grade_id') + ->join('institution_classes', function($join) use ($educationGradeId, $academicPeriodId) { $join->on('institution_classes.institution_id', '=', 'institution_grades.institution_id') ->where('institution_classes.academic_period_id', $academicPeriodId) - ->join('institution_class_grades', function ($join) use ($educationGradeId) { + ->join('institution_class_grades', function($join) use ($educationGradeId) { $join->on('institution_class_grades.institution_class_id', '=', 'institution_classes.id') ->where('institution_class_grades.education_grade_id', $educationGradeId); }); @@ -83,7 +83,7 @@ public function getParallelClasses($id, $institutionId, $educationGradeId, $acad ->where('institution_grades.education_grade_id', $educationGradeId) ->where('institution_grades.institution_id', $institutionId) ->get(); - }else{ + }else { return null; } } @@ -95,8 +95,8 @@ public function getParallelClasses($id, $institutionId, $educationGradeId, $acad * @param $year * @param $id */ - public function updatePromoted($year, $id){ - self::where('id',$id)->update(['promoted'=>$year]); + public function updatePromoted($year, $id) { + self::where('id', $id)->update(['promoted'=>$year]); } /** @@ -107,8 +107,8 @@ public function updatePromoted($year, $id){ * @return mixed */ public function getInstitutionGrade($institutionId, $gradeId){ - return self::where('education_grade_id',$gradeId) - ->where('institution_id',$institutionId)->get()->first(); + return self::where('education_grade_id',$gradeId) + ->where('institution_id',$institutionId)->get()->first(); } /** @@ -116,14 +116,14 @@ public function getInstitutionGrade($institutionId, $gradeId){ * @param null $institution * @return mixed */ - public function getInstitutionGradeToPromoted($year, $institution = null){ + public function getInstitutionGradeToPromoted($year, $institution = null) { return self::query() - ->select('education_grades.name','institutions.code','institutions.name as institution_name','institution_grades.id','institution_grades.institution_id','institution_grades.education_grade_id') - ->where('promoted','=',$year-1) - ->join('education_grades','institution_grades.education_grade_id','=','education_grades.id') - ->join('institutions', function($join) use ($year,$institution){ - $join->on('institutions.id','=','institution_grades.institution_id') - ->where('institutions.code','=',$institution); + ->select('education_grades.name', 'institutions.code', 'institutions.name as institution_name', 'institution_grades.id', 'institution_grades.institution_id', 'institution_grades.education_grade_id') + ->where('promoted', '=', $year - 1) + ->join('education_grades', 'institution_grades.education_grade_id', '=', 'education_grades.id') + ->join('institutions', function($join) use ($year, $institution){ + $join->on('institutions.id', '=', 'institution_grades.institution_id') + ->where('institutions.code', '=', $institution); }) ->orderBy('institution_id') ->get()->toArray(); @@ -133,13 +133,13 @@ public function getInstitutionGradeToPromoted($year, $institution = null){ * @param $year * @return mixed */ - public function getInstitutionGradeList($year){ + public function getInstitutionGradeList($year) { return self::query() - ->select('education_grades.name','institutions.code','institutions.name as institution_name','institution_grades.id','institution_grades.institution_id','institution_grades.education_grade_id') - ->where('promoted','=',$year-1) - ->join('education_grades','institution_grades.education_grade_id','=','education_grades.id') + ->select('education_grades.name', 'institutions.code', 'institutions.name as institution_name', 'institution_grades.id', 'institution_grades.institution_id', 'institution_grades.education_grade_id') + ->where('promoted', '=', $year - 1) + ->join('education_grades', 'institution_grades.education_grade_id', '=', 'education_grades.id') ->join('institutions', function($join) use ($year){ - $join->on('institutions.id','=','institution_grades.institution_id'); + $join->on('institutions.id', '=', 'institution_grades.institution_id'); }) ->orderBy('institution_id') ->get()->first(); diff --git a/app/Models/Institution_shift.php b/app/Models/Institution_shift.php index a6f605e4..380bad7f 100755 --- a/app/Models/Institution_shift.php +++ b/app/Models/Institution_shift.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution_shift extends Base_Model { +class Institution_shift extends Base_Model { /** * The database table used by the model. @@ -42,7 +42,7 @@ class Institution_shift extends Base_Model { protected $dates = ['modified', 'created']; public function shiftExists($shift){ - return self::query() + return self::query() ->where('institution_id',$shift['institution_id']) ->where('location_institution_id',$shift['location_institution_id']) ->where('shift_option_id',$shift['shift_option_id']) diff --git a/app/Models/Institution_staff.php b/app/Models/Institution_staff.php index e98bbe6c..eb7bbdff 100755 --- a/app/Models/Institution_staff.php +++ b/app/Models/Institution_staff.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution_staff extends Model { +class Institution_staff extends Model { /** * The database table used by the model. @@ -42,12 +42,12 @@ class Institution_staff extends Model { protected $dates = ['start_date', 'end_date', 'modified', 'created']; - public function staff_class(){ - return $this->hasMany('App\Models\Institution_class','staff_id','staff_id'); + public function staff_class() { + return $this->hasMany('App\Models\Institution_class', 'staff_id', 'staff_id'); } - public function institution(){ - return $this->belongsTo('App\Models\Institution','institution_id'); + public function institution() { + return $this->belongsTo('App\Models\Institution', 'institution_id'); } diff --git a/app/Models/Institution_student.php b/app/Models/Institution_student.php index a833126c..abad9e54 100755 --- a/app/Models/Institution_student.php +++ b/app/Models/Institution_student.php @@ -7,7 +7,7 @@ use Webpatser\Uuid\Uuid; -class Institution_student extends Base_Model { +class Institution_student extends Base_Model { public const CREATED_AT = 'created'; @@ -31,7 +31,7 @@ class Institution_student extends Base_Model { * * @var array */ - protected $fillable = ['student_status_id', 'student_id', 'education_grade_id', 'academic_period_id', 'start_date', 'start_year', 'end_date', 'end_year', 'institution_id', 'previous_institution_student_id', 'modified_user_id', 'modified', 'created_user_id', 'created', 'area_administrative_id','admission_id']; + protected $fillable = ['student_status_id', 'student_id', 'education_grade_id', 'academic_period_id', 'start_date', 'start_year', 'end_date', 'end_year', 'institution_id', 'previous_institution_student_id', 'modified_user_id', 'modified', 'created_user_id', 'created', 'area_administrative_id', 'admission_id']; /** * The attributes excluded from the model's JSON form. @@ -50,8 +50,8 @@ class Institution_student extends Base_Model { /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function institutionStudents(){ - return $this->belongsTo('App\Security_user','student_id'); + public function institutionStudents() { + return $this->belongsTo('App\Security_user', 'student_id'); } /** @@ -60,7 +60,7 @@ public function institutionStudents(){ public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); $model->created = now(); }); @@ -77,9 +77,9 @@ public static function boot() * * */ - public static function isDuplicated($inputs){ + public static function isDuplicated($inputs) { - $exists = self::where('student_id','=',$inputs['student_id'])->count(); + $exists = self::where('student_id', '=', $inputs['student_id'])->count(); return $exists; @@ -100,12 +100,12 @@ public static function isDuplicated($inputs){ * @param $academicPeriod * @return array */ - public function getStudentListToPromote($institutionGrade, $academicPeriod){ + public function getStudentListToPromote($institutionGrade, $academicPeriod) { return self::query() - ->select('institution_students.id','institution_students.student_id','institution_students.student_status_id', - 'institution_students.education_grade_id','institution_students.education_grade_id', - 'institution_students.academic_period_id','institution_students.institution_id', - 'institution_students.created_user_id','institution_students.admission_id') + ->select('institution_students.id', 'institution_students.student_id', 'institution_students.student_status_id', + 'institution_students.education_grade_id', 'institution_students.education_grade_id', + 'institution_students.academic_period_id', 'institution_students.institution_id', + 'institution_students.created_user_id', 'institution_students.admission_id') ->where('institution_students.institution_id', $institutionGrade['institution_id']) ->where('institution_students.education_grade_id', $institutionGrade['education_grade_id']) ->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray(); diff --git a/app/Models/Institution_student_admission.php b/app/Models/Institution_student_admission.php index 979f59fc..a27538a8 100755 --- a/app/Models/Institution_student_admission.php +++ b/app/Models/Institution_student_admission.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution_student_admission extends Base_Model { +class Institution_student_admission extends Base_Model { public const CREATED_AT = 'created'; diff --git a/app/Models/Institution_subject.php b/app/Models/Institution_subject.php index e0a1a89a..f271a147 100755 --- a/app/Models/Institution_subject.php +++ b/app/Models/Institution_subject.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution_subject extends Base_Model { +class Institution_subject extends Base_Model { /** * The database table used by the model. @@ -42,28 +42,28 @@ class Institution_subject extends Base_Model { protected $dates = ['modified', 'created', 'modified', 'created']; - public function institutionGradeSubject(){ - return $this->belongsTo('App\Models\Education_grades_subject','education_subject_id','education_subject_id'); + public function institutionGradeSubject() { + return $this->belongsTo('App\Models\Education_grades_subject', 'education_subject_id', 'education_subject_id'); } - public function institutionOptionalGradeSubject(){ - return $this->belongsTo('App\Models\Education_grades_subject','education_grade_id','education_grade_id'); + public function institutionOptionalGradeSubject() { + return $this->belongsTo('App\Models\Education_grades_subject', 'education_grade_id', 'education_grade_id'); } - public function institutionMandatoryGradeSubject(){ - return $this->belongsTo('App\Models\Education_grades_subject','education_grade_id','education_grade_id'); + public function institutionMandatoryGradeSubject() { + return $this->belongsTo('App\Models\Education_grades_subject', 'education_grade_id', 'education_grade_id'); } - public function institutionClassSubject(){ - return $this->hasMany('App\Models\Institution_class_subject','institution_class_id','id'); + public function institutionClassSubject() { + return $this->hasMany('App\Models\Institution_class_subject', 'institution_class_id', 'id'); } - public function getInstitutionSubjects($institution_id,$academic_period_id){ - return self::query()->where('institution_id',$institution_id) - ->where('academic_period_id',$academic_period_id) + public function getInstitutionSubjects($institution_id, $academic_period_id) { + return self::query()->where('institution_id', $institution_id) + ->where('academic_period_id', $academic_period_id) ->get()->toArray(); } diff --git a/app/Models/Institution_subject_student.php b/app/Models/Institution_subject_student.php index 936e53e8..b6ac5f24 100755 --- a/app/Models/Institution_subject_student.php +++ b/app/Models/Institution_subject_student.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; use Webpatser\Uuid\Uuid; -class Institution_subject_student extends Model { +class Institution_subject_student extends Model { public const CREATED_AT = 'created'; @@ -51,7 +51,7 @@ class Institution_subject_student extends Model { public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); }); @@ -71,21 +71,21 @@ public static function boot() */ public static function isDuplicated($inputs){ - $exists = self::where('student_id','=',$inputs['student_id']) - ->where('institution_subject_id','=',$inputs['institution_subject_id']) - ->where('education_subject_id','=',$inputs['education_subject_id'])->count(); + $exists = self::where('student_id','=',$inputs['student_id']) + ->where('institution_subject_id','=',$inputs['institution_subject_id']) + ->where('education_subject_id','=',$inputs['education_subject_id'])->count(); return $exists ? true :false; } - public function student(){ + public function student(){ return $this->belongsTo('App\Models\Security_user','student_id'); } public static function getStudentsCount(){ - $total_male_students = self::with(['student' => function($query) { + $total_male_students = self::with(['student' => function($query) { $query->where('student.gender_id', '=', 1); }])->whereHas('student', function ($query) { $query->where('gender_id', '=', 1); diff --git a/app/Models/Institution_subjects_room.php b/app/Models/Institution_subjects_room.php index 0947049f..5d87b521 100755 --- a/app/Models/Institution_subjects_room.php +++ b/app/Models/Institution_subjects_room.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Institution_subjects_room extends Model { +class Institution_subjects_room extends Model { /** * The database table used by the model. diff --git a/app/Models/Nationality.php b/app/Models/Nationality.php index 61ebbd34..5cc4fc7f 100755 --- a/app/Models/Nationality.php +++ b/app/Models/Nationality.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Nationality extends Model { +class Nationality extends Model { /** * The database table used by the model. diff --git a/app/Models/Security_group.php b/app/Models/Security_group.php index 577fdf2b..af4ef37d 100755 --- a/app/Models/Security_group.php +++ b/app/Models/Security_group.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Security_group extends Model { +class Security_group extends Model { /** * The database table used by the model. @@ -45,13 +45,13 @@ class Security_group extends Model { // return $this->hasMany( User::class); // } - public function security_users(){ - return $this->belongsTo('App\Models\Security_group_user','security_group_id'); + public function security_users() { + return $this->belongsTo('App\Models\Security_group_user', 'security_group_id'); } - public function security_group_institution(){ - return $this->hasMany('App\Models\Security_group_institution','security_group_id'); + public function security_group_institution() { + return $this->hasMany('App\Models\Security_group_institution', 'security_group_id'); } } \ No newline at end of file diff --git a/app/Models/Security_group_institution.php b/app/Models/Security_group_institution.php index 2b131664..0cbee537 100755 --- a/app/Models/Security_group_institution.php +++ b/app/Models/Security_group_institution.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Security_group_institution extends Model { +class Security_group_institution extends Model { /** @@ -44,16 +44,16 @@ class Security_group_institution extends Model { - public function institution(){ - return $this->belongsTo('App\Models\Institution','institution_id'); + public function institution() { + return $this->belongsTo('App\Models\Institution', 'institution_id'); } - public function institution_classes(){ - return $this->hasMany('App\Models\Institution_class','institution_id','institution_id'); + public function institution_classes() { + return $this->hasMany('App\Models\Institution_class', 'institution_id', 'institution_id'); } - public function security_group(){ - return $this->belongsTo('App\Models\Security_group','security_group_id'); + public function security_group() { + return $this->belongsTo('App\Models\Security_group', 'security_group_id'); } } \ No newline at end of file diff --git a/app/Models/Security_group_user.php b/app/Models/Security_group_user.php index 7e548b95..deee097c 100755 --- a/app/Models/Security_group_user.php +++ b/app/Models/Security_group_user.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Security_group_user extends Model { +class Security_group_user extends Model { public const CREATED_AT = 'created'; public const UPDATED_AT = 'modified'; @@ -45,34 +45,34 @@ class Security_group_user extends Model { protected $dates = ['modified', 'created', 'created']; - public function security_user(){ - return $this->belongsToMany('App\Models\User','security_users'); + public function security_user() { + return $this->belongsToMany('App\Models\User', 'security_users'); } - public function security_group(){ - return $this->hasMany('App\Models\Security_group' , 'id','security_group_id'); + public function security_group() { + return $this->hasMany('App\Models\Security_group', 'id', 'security_group_id'); } - public function security_group_institution(){ - return $this->belongsTo('App\Models\Security_group_institution','security_group_id','security_group_id'); + public function security_group_institution() { + return $this->belongsTo('App\Models\Security_group_institution', 'security_group_id', 'security_group_id'); } - public function staff_class(){ - return $this->hasMany('App\Models\Institution_class','staff_id','security_user_id'); + public function staff_class() { + return $this->hasMany('App\Models\Institution_class', 'staff_id', 'security_user_id'); } - public function institution_staff(){ - return $this->belongsTo('App\Models\Institution_staff','security_user_id','staff_id'); + public function institution_staff() { + return $this->belongsTo('App\Models\Institution_staff', 'security_user_id', 'staff_id'); } - public function institution_group(){ - return $this->hasMany('App\Models\Security_group_institution','security_group_id','security_group_id') - ->with(['institution','institution_classes']); + public function institution_group() { + return $this->hasMany('App\Models\Security_group_institution', 'security_group_id', 'security_group_id') + ->with(['institution', 'institution_classes']); } - public function roles(){ - return $this->belongsTo('App\Models\Security_role','security_role_id','id'); + public function roles() { + return $this->belongsTo('App\Models\Security_role', 'security_role_id', 'id'); } diff --git a/app/Models/Security_role.php b/app/Models/Security_role.php index 9b812255..68eed5cb 100755 --- a/app/Models/Security_role.php +++ b/app/Models/Security_role.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Security_role extends Model { +class Security_role extends Model { /** * The database table used by the model. @@ -42,8 +42,8 @@ class Security_role extends Model { protected $dates = ['modified', 'created']; - public function securityUsers(){ - return $this->belongsToMany(Security_group_user::class,'security_group_users','security_group_id','security_group_id'); + public function securityUsers() { + return $this->belongsToMany(Security_group_user::class, 'security_group_users', 'security_group_id', 'security_group_id'); } diff --git a/app/Models/Security_user.php b/app/Models/Security_user.php index 67955c31..bf391f45 100755 --- a/app/Models/Security_user.php +++ b/app/Models/Security_user.php @@ -8,7 +8,7 @@ use Webpatser\Uuid\Uuid; -class Security_user extends Base_Model { +class Security_user extends Base_Model { public const CREATED_AT = 'created'; public const UPDATED_AT = 'modified'; @@ -23,7 +23,7 @@ class Security_user extends Base_Model { protected $table = 'security_users'; protected $appends = [ - 'special_need_name' + 'special_need_name' ]; /** @@ -83,13 +83,13 @@ public function getSpecialNeedNameAttribute() { */ protected $casts = []; - public function institutionStudents(){ - return $this->hasOne(Institution_student::class,'student_id'); + public function institutionStudents() { + return $this->hasOne(Institution_student::class, 'student_id'); } - public function institutionStudentsClass(){ + public function institutionStudentsClass() { return $this->hasOne(Institution_student::class, 'student_id'); } @@ -104,7 +104,7 @@ public function institutionStudentsClass(){ - public function rules() + public function rules() { return [ 'identity_number' => [ @@ -126,7 +126,7 @@ public function getAuthPassword(){ } public function uploads(){ - return $this->hasMany('App\Models\Upload'); + return $this->hasMany('App\Models\Upload'); } public function class(){ diff --git a/app/Models/Special_need_difficulty.php b/app/Models/Special_need_difficulty.php index 372dfc9a..df4d8349 100755 --- a/app/Models/Special_need_difficulty.php +++ b/app/Models/Special_need_difficulty.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Special_need_difficulty extends Model { +class Special_need_difficulty extends Model { /** * The database table used by the model. diff --git a/app/Models/Student_guardian.php b/app/Models/Student_guardian.php index b2c9c270..51afb720 100755 --- a/app/Models/Student_guardian.php +++ b/app/Models/Student_guardian.php @@ -6,7 +6,7 @@ use App\Models\Base_Model; use Webpatser\Uuid\Uuid; -class Student_guardian extends Base_Model { +class Student_guardian extends Base_Model { public const CREATED_AT = 'created'; @@ -55,13 +55,13 @@ class Student_guardian extends Base_Model { public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); $model->created_user_id = 1; }); } - public static function createStudentGuardian($student,$guardian,$user){ + public static function createStudentGuardian($student, $guardian, $user) { $data = [ 'student_id' => $student->student_id, diff --git a/app/Models/Upload.php b/app/Models/Upload.php index d1cbf752..ee833314 100755 --- a/app/Models/Upload.php +++ b/app/Models/Upload.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Upload extends Model { +class Upload extends Model { /** * The database table used by the model. @@ -43,12 +43,12 @@ class Upload extends Model { public $timestamps = true; - public function user(){ - return $this->belongsTo('App\Models\Security_user','security_user_id'); + public function user() { + return $this->belongsTo('App\Models\Security_user', 'security_user_id'); } - public function classRoom(){ - return $this->belongsTo('App\Models\Institution_class','institution_class_id'); + public function classRoom() { + return $this->belongsTo('App\Models\Institution_class', 'institution_class_id'); } } diff --git a/app/Models/User.php b/app/Models/User.php index cb421826..ff800a85 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -7,7 +7,7 @@ use Laravel\Passport\HasApiTokens; -class User extends Authenticatable { +class User extends Authenticatable { use HasApiTokens, Notifiable; @@ -71,8 +71,8 @@ class User extends Authenticatable { public function permissions(){ return $this->hasMany('App\Models\Security_group_user','security_user_id','id') - ->where('security_group_users.security_role_id','=',5) - ->with(['security_group_institution','institution_staff','security_group' , 'staff_class','institution_group' , 'roles']); + ->where('security_group_users.security_role_id','=',5) + ->with(['security_group_institution','institution_staff','security_group' , 'staff_class','institution_group' , 'roles']); } public function principal(){ diff --git a/app/Models/User_body_mass.php b/app/Models/User_body_mass.php index cefead63..5c4157e1 100755 --- a/app/Models/User_body_mass.php +++ b/app/Models/User_body_mass.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class User_body_mass extends Base_Model { +class User_body_mass extends Base_Model { /** * The database table used by the model. diff --git a/app/Models/User_contact.php b/app/Models/User_contact.php index 0296b73c..d19c5c9c 100644 --- a/app/Models/User_contact.php +++ b/app/Models/User_contact.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class User_contact extends Base_Model { +class User_contact extends Base_Model { /** * The database table used by the model. @@ -41,14 +41,14 @@ class User_contact extends Base_Model { */ protected $dates = ['modified', 'created']; - public static function createOrUpdate($data,$user){ + public static function createOrUpdate($data, $user) { - if(!is_null($data['contact'])){ + if (!is_null($data['contact'])) { $exists = self::where('security_user_id', $data->id) - ->where('value',$data['contact']) + ->where('value', $data['contact']) ->first(); - if(is_null($exists)){ + if (is_null($exists)) { $data = [ 'security_user_id' => $data->id, 'value' => $data['contact'], @@ -58,7 +58,7 @@ public static function createOrUpdate($data,$user){ 'preferred' => 1 ]; self::updateOrCreate($data); - }else{ + }else { $exists = $exists->toArray(); $exists['preferred'] = 1; $exists['value'] = $data['contact']; diff --git a/app/Models/User_identity.php b/app/Models/User_identity.php index 7e45296e..fc63bc88 100755 --- a/app/Models/User_identity.php +++ b/app/Models/User_identity.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Webpatser\Uuid\Uuid; -class User_identity extends Model { +class User_identity extends Model { public const CREATED_AT = 'created'; public const UPDATED_AT = 'modified'; diff --git a/app/Models/User_nationality.php b/app/Models/User_nationality.php index 153cf2ad..72811f49 100755 --- a/app/Models/User_nationality.php +++ b/app/Models/User_nationality.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Webpatser\Uuid\Uuid; -class User_nationality extends Base_Model { +class User_nationality extends Base_Model { /** * The database table used by the model. @@ -47,7 +47,7 @@ class User_nationality extends Base_Model { public static function boot() { parent::boot(); - self::creating(function ($model) { + self::creating(function($model) { $model->id = (string) Uuid::generate(4); }); diff --git a/app/Models/User_special_need.php b/app/Models/User_special_need.php index 40bf8652..84166a76 100755 --- a/app/Models/User_special_need.php +++ b/app/Models/User_special_need.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class User_special_need extends Base_Model { +class User_special_need extends Base_Model { /** * The database table used by the model. @@ -42,11 +42,11 @@ class User_special_need extends Base_Model { protected $dates = ['special_need_date', 'modified', 'created']; - public static function isDuplicated($inputs){ + public static function isDuplicated($inputs){ - $exists = self::where('security_user_id','=',$inputs['security_user_id']) - ->where('special_need_type_id','=',$inputs['special_need_type_id']) - ->where('special_need_difficulty_id','=',$inputs['special_need_difficulty_id'])->count(); + $exists = self::where('security_user_id','=',$inputs['security_user_id']) + ->where('special_need_type_id','=',$inputs['special_need_type_id']) + ->where('special_need_difficulty_id','=',$inputs['special_need_difficulty_id'])->count(); // dd($exists); return $exists == 0 ? true :false; diff --git a/app/Models/Workflow_transition.php b/app/Models/Workflow_transition.php index f17230ea..e5fcbd7c 100755 --- a/app/Models/Workflow_transition.php +++ b/app/Models/Workflow_transition.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -class Workflow_transition extends Model { +class Workflow_transition extends Model { public const CREATED_AT = 'created'; public const UPDATED_AT = 'modified'; diff --git a/app/Permissions/HasPermissionsTrait.php b/app/Permissions/HasPermissionsTrait.php index 288abc99..f4c8961d 100755 --- a/app/Permissions/HasPermissionsTrait.php +++ b/app/Permissions/HasPermissionsTrait.php @@ -7,12 +7,12 @@ trait HasPermissionsTrait { - public function roles(){ - return $this->belongsToMany(Security_group_user::class,'security_group_users'); + public function roles() { + return $this->belongsToMany(Security_group_user::class, 'security_group_users'); } - public function hasRole( ... $roles ) { + public function hasRole(... $roles) { foreach ($roles as $role) { if ($this->roles->contains('code', $role)) { return true; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index afc6440b..dede705d 100755 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -25,11 +25,11 @@ public function register() * * @return void */ - public function boot() - { - // - if((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { - URL::forceScheme('https'); - } - } + public function boot() + { + // + if((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { + URL::forceScheme('https'); + } + } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 5ea48d39..ec09585c 100755 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -52,8 +52,8 @@ public function map() protected function mapWebRoutes() { Route::middleware('web') - ->namespace($this->namespace) - ->group(base_path('routes/web.php')); + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); } /** @@ -66,8 +66,8 @@ protected function mapWebRoutes() protected function mapApiRoutes() { Route::prefix('api') - ->middleware('api') - ->namespace($this->namespace) - ->group(base_path('routes/api.php')); + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); } } diff --git a/app/Providers/ShaHashServiceProvider.php b/app/Providers/ShaHashServiceProvider.php index c0972c5a..f30b474c 100755 --- a/app/Providers/ShaHashServiceProvider.php +++ b/app/Providers/ShaHashServiceProvider.php @@ -12,7 +12,7 @@ class ShaHashServiceProvider extends HashServiceProvider public function register() { - $this->app->singleton('hash',function (){ + $this->app->singleton('hash', function() { return new SHAHasher($this->app); }); } diff --git a/app/Providers/ValidationExtensionServiceProvider.php b/app/Providers/ValidationExtensionServiceProvider.php index f8ad9ede..cccc6822 100755 --- a/app/Providers/ValidationExtensionServiceProvider.php +++ b/app/Providers/ValidationExtensionServiceProvider.php @@ -11,7 +11,7 @@ public function register() {} public function boot() { $this->app->validator->resolver( function( $translator, $data, $rules, - $messages = array(), $customAttributes = array() ) { + $messages = array(), $customAttributes = array() ) { return new ValidatorExtended( $translator, $data, $rules, $messages, $customAttributes ); } ); diff --git a/app/Providers/ValidatorExtended.php b/app/Providers/ValidatorExtended.php index 16994cc9..23f4edc4 100755 --- a/app/Providers/ValidatorExtended.php +++ b/app/Providers/ValidatorExtended.php @@ -56,43 +56,43 @@ protected function validateAdmissionAge($attribute, $value, $parameters, $valida if (empty($value)) { return false; } elseif ($gradeEntity !== null) { - $admissionAge = (($gradeEntity->admission_age)*12)-1; + $admissionAge = (($gradeEntity->admission_age)*12) - 1; $to = $academicPeriod->start_date; $diff_in_months = $to->diffInMonths($value); $ageOfStudent = $diff_in_months; $enrolmentMaximumAge = $admissionAge + 120; return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); - } else { + }else { return false; } } protected function validateBmi($attribute, $value, $parameters) { - $bmiGrades = ['G1','G4','G7','G10']; + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) - ->join('education_grades','institution_class_grades.education_grade_id','education_grades.id') + ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') ->first(); - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); - if(in_array($institutionGrade->code,$bmiGrades)){ - if(!empty($value)){ - if(($attribute == 'bmi_height') || ('bmi_weight')){ + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); + if (in_array($institutionGrade->code, $bmiGrades)) { + if (!empty($value)) { + if (($attribute == 'bmi_height') || ('bmi_weight')) { $v = Validator::make([$attribute => $value], [ $attribute => 'number|min:10|max:200' ]); - if($v->fails()) { - $this->_custom_messages['bmi'] = $attribute.' is not a valid input'; + if ($v->fails()) { + $this->_custom_messages['bmi'] = $attribute.' is not a valid input'; $this->_set_custom_stuff(); return false; } return true; } - }else{ - $this->_custom_messages['bmi'] = $attribute.' is required for '. $educationGrade->name; + }else { + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; $this->_set_custom_stuff(); return false; } - }else{ + }else { return true; } } @@ -125,23 +125,23 @@ protected function validateIsStudentInClass($attribute, $value, $perameters, $va $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id','=',$perameters[0])->count(); if($check == 1){ return true; - }else{ + } else{ return false; } - }else{ + } else{ return false; } } protected function validateNic($attribute, $value, $perameters, $validator){ $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value); - if(!$valid){ - $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; - $this->_set_custom_stuff(); - return false; - }else{ - return true; - } + if(!$valid){ + $this->_custom_messages['nic'] = $attribute. ' is not valid, Please check the NIC number'; + $this->_set_custom_stuff(); + return false; + }else{ + return true; + } } protected function validateUserUnique($attribute, $value, $perameters, $validator) { @@ -161,39 +161,39 @@ protected function validateUserUnique($attribute, $value, $perameters, $validato protected function validateIsBc($attribute, $value, $perameters, $validator) { foreach ($validator->getData() as $data) { - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); if (($identityType !== null) && ($identityType !== "")) { if (($identityType->national_code) === 'BC') { return (strlen((string) $data['identity_number']) < 7); - } else { + }else { return true; } - } else { + }else { return true; } } } - protected function checkUnique($value, $data,$identityType) { + protected function checkUnique($value, $data, $identityType) { $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); if ($isUnique->count() > 0) { - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; $this->_set_custom_stuff(); return false; - } else { + }else { return true; } } protected function IsBc($data, $value) { - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); if ($identityType !== null) { if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { return false; - } else { + }else { return true; } - } else { + }else { return true; } } diff --git a/app/helpers.php b/app/helpers.php index 6a6e5ded..6a6119e5 100755 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,16 +1,16 @@ 1){ - for ($i = 0; ($length-1) > $i; $i++) { - $Initials = $Initials . '' . mb_substr($names[$i], 0, 1, "UTF-8"); + if ($length > 1) { + for ($i = 0; ($length - 1) > $i; $i++) { + $Initials = $Initials.''.mb_substr($names[$i], 0, 1, "UTF-8"); } - $nameWithInitials = $Initials . ' ' . $names[$length - 1]; - }else{ + $nameWithInitials = $Initials.' '.$names[$length - 1]; + }else { $nameWithInitials = $fullname; } return $nameWithInitials; @@ -23,16 +23,16 @@ function array_keys_exists(array $keys, array $arr) } function clean($string) { - $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. + $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. - return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. + return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. } -function getMatchingKeys($array){ +function getMatchingKeys($array) { $keys = []; - foreach ($array as $key => $value){ - if(strstr($key , 'option')) + foreach ($array as $key => $value) { + if (strstr($key, 'option')) $keys[] = $key; } return $keys; @@ -42,7 +42,7 @@ function is_sha1($str) { return (bool) preg_match('/^[0-9a-f]{40}$/i', $str); } -function isEmpty($value){ +function isEmpty($value) { return $value['institution_optional_subject'] !== null; } @@ -51,7 +51,7 @@ function unique_multidim_array(array $array, $key) { $i = 0; $key_array = array(); - foreach($array as $val) { + foreach ($array as $val) { if (!in_array($val[$key], $key_array)) { $key_array[$i] = $val[$key]; $temp_array[$i] = $val; @@ -63,10 +63,10 @@ function unique_multidim_array(array $array, $key) { -function merge_two_arrays($array1,$array2) { +function merge_two_arrays($array1, $array2) { $data = array(); - $arrayAB = array_merge($array1,$array2); + $arrayAB = array_merge($array1, $array2); foreach ($arrayAB as $value) { dd($arrayAB); @@ -74,25 +74,25 @@ function merge_two_arrays($array1,$array2) { if (!isset($data[$id])) { $data[$id] = array(); } - $data[$id] = array_merge($data[$id],$value); + $data[$id] = array_merge($data[$id], $value); } return $data; } -function array_value_recursive($key, array $arr){ +function array_value_recursive($key, array $arr) { $val = array(); array_walk_recursive($arr, function($v, $k) use($key, &$val){ - if($k == $key) array_push($val, $v); + if ($k == $key) array_push($val, $v); }); return count($val) > 1 ? $val : array_pop($val); } -function merge_error_by_row($errors,$key){ +function merge_error_by_row($errors, $key) { $temp_array = array(); $i = 0; - foreach($errors as $keys => $val) { + foreach ($errors as $keys => $val) { if (!in_array($val[$key], $temp_array)) { $temp_array[$keys]['errors'][] = $val; } @@ -108,17 +108,17 @@ function merge_error_by_row($errors,$key){ * bind error messages to the excel file */ -function append_errors_to_excel($error, $count, $reader){ +function append_errors_to_excel($error, $count, $reader) { $active_sheet = $reader->getActiveSheet(); $prev_value = $active_sheet->getCell('A'.$error['row'])->getValue(); - $active_sheet->setCellValue('A'. ($error['row']) , $prev_value.','.implode(',',$error['errors'])); - $active_sheet->getStyle('A'. ($error['row']))->getAlignment()->setWrapText(true); + $active_sheet->setCellValue('A'.($error['row']), $prev_value.','.implode(',', $error['errors'])); + $active_sheet->getStyle('A'.($error['row']))->getAlignment()->setWrapText(true); $columns = Illuminate\Support\Facades\Config::get('excel.columns'); - $column = array_keys($columns,$error['attribute']); - if(!empty($column)){ - $column = $column[0]+1; - $selectedCells = $active_sheet->setSelectedCellByColumnAndRow($column,$error['row']); + $column = array_keys($columns, $error['attribute']); + if (!empty($column)) { + $column = $column[0] + 1; + $selectedCells = $active_sheet->setSelectedCellByColumnAndRow($column, $error['row']); $active_cell = ($selectedCells->getActiveCell()); $active_sheet->getStyle($active_cell) @@ -130,23 +130,23 @@ function append_errors_to_excel($error, $count, $reader){ } } -function rows($error){ +function rows($error) { return $error['row']; } -function rowIndex($row){ +function rowIndex($row) { return $row->getRowIndex(); } -function removeRows($row,$param){ - if(in_array($row,$param['rows'])){ +function removeRows($row, $param) { + if (in_array($row, $param['rows'])) { $param['reader']->getActiveSheet()->removeRow($row); } } -function colorizeCell($column,$error,$active_sheet){ - $column = array_keys($column,$error['attribute']); - $selectedCells = $active_sheet->setSelectedCellByColumnAndRow($column,$error['row']); +function colorizeCell($column, $error, $active_sheet) { + $column = array_keys($column, $error['attribute']); + $selectedCells = $active_sheet->setSelectedCellByColumnAndRow($column, $error['row']); $active_cell = ($selectedCells->getActiveCell()); $active_sheet->getStyle($active_cell) @@ -158,14 +158,14 @@ function colorizeCell($column,$error,$active_sheet){ } -function errors_unique_array($item,$key){ +function errors_unique_array($item, $key) { - $search = array_filter($item,function ($data) use ($item){ - return isset($data['row']) && ($data['row'] == $item->row()); + $search = array_filter($item, function($data) use ($item){ + return isset($data['row']) && ($data['row'] == $item->row()); }); - if($search){ - array_push($search[0]['errors'],implode(',',$item->errors())); + if ($search) { + array_push($search[0]['errors'], implode(',', $item->errors())); $errors = $search; } @@ -173,7 +173,7 @@ function errors_unique_array($item,$key){ } function isEmptyRow($row) { - foreach($row as $cell){ + foreach ($row as $cell) { if (null !== $cell) return false; } return true;