| @@ -54,10 +54,10 @@ discard block | ||
| 54 | 54 | /** | 
| 55 | 55 | * @return string | 
| 56 | 56 | */ | 
| 57 | -    public function findUsername(){ | |
| 57 | +    public function findUsername() { | |
| 58 | 58 |          $login = request()->input('username'); | 
| 59 | 59 | |
| 60 | - $fieldType = filter_var($login,FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; | |
| 60 | + $fieldType = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; | |
| 61 | 61 | |
| 62 | 62 | request()->merge([$fieldType => $login]); | 
| 63 | 63 | |
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 | /** | 
| 68 | 68 | * @return string | 
| 69 | 69 | */ | 
| 70 | -    public function username(){ | |
| 70 | +    public function username() { | |
| 71 | 71 | return $this->username; | 
| 72 | 72 | } | 
| 73 | 73 | } | 
| @@ -7,12 +7,12 @@ | ||
| 7 | 7 | |
| 8 | 8 | trait HasPermissionsTrait | 
| 9 | 9 |  { | 
| 10 | -    public function roles(){ | |
| 11 | - return $this->belongsToMany(Security_group_user::class,'security_group_users'); | |
| 10 | +    public function roles() { | |
| 11 | + return $this->belongsToMany(Security_group_user::class, 'security_group_users'); | |
| 12 | 12 | } | 
| 13 | 13 | |
| 14 | 14 | |
| 15 | -    public function hasRole( ... $roles ) { | |
| 15 | +    public function hasRole(... $roles) { | |
| 16 | 16 |          foreach ($roles as $role) { | 
| 17 | 17 |              if ($this->roles->contains('code', $role)) { | 
| 18 | 18 | return true; | 
| @@ -40,7 +40,7 @@ | ||
| 40 | 40 | // TODO: Implement registerEvents() method. | 
| 41 | 41 | |
| 42 | 42 | return [ | 
| 43 | -            BeforeSheet::class => function(BeforeSheet $event){ | |
| 43 | +            BeforeSheet::class => function(BeforeSheet $event) { | |
| 44 | 44 | $this->sheetNames[] = $event->getSheet()->getTitle(); | 
| 45 | 45 | |
| 46 | 46 | } | 
| @@ -10,10 +10,10 @@ | ||
| 10 | 10 |      public function register() {} | 
| 11 | 11 | |
| 12 | 12 |      public function boot() { | 
| 13 | - $this->app->validator->resolver( function( $translator, $data, $rules, | |
| 14 | -                                                   $messages = array(), $customAttributes = array() ) { | |
| 15 | - return new ValidatorExtended( $translator, $data, $rules, $messages, | |
| 16 | - $customAttributes ); | |
| 13 | + $this->app->validator->resolver(function($translator, $data, $rules, | |
| 14 | +                                                   $messages = array(), $customAttributes = array()) { | |
| 15 | + return new ValidatorExtended($translator, $data, $rules, $messages, | |
| 16 | + $customAttributes); | |
| 17 | 17 | } ); | 
| 18 | 18 | } | 
| 19 | 19 | } | 
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | |
| 13 | 13 | public function register() | 
| 14 | 14 |      { | 
| 15 | -        $this->app->singleton('hash',function (){ | |
| 15 | +        $this->app->singleton('hash', function() { | |
| 16 | 16 | return new SHAHasher($this->app); | 
| 17 | 17 | }); | 
| 18 | 18 | } | 
| @@ -45,19 +45,19 @@ discard block | ||
| 45 | 45 |      { | 
| 46 | 46 | $files = $this->getFiles(); | 
| 47 | 47 |              try { | 
| 48 | -                if(!empty($files)){ | |
| 49 | - array_walk($files,array($this,'process')); | |
| 48 | +                if (!empty($files)) { | |
| 49 | + array_walk($files, array($this, 'process')); | |
| 50 | 50 | unset($files); | 
| 51 | 51 | exit(); | 
| 52 | 52 | |
| 53 | -                }else{ | |
| 53 | +                }else { | |
| 54 | 54 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); | 
| 55 | 55 |                      $output->writeln('No files found,Waiting for files'); | 
| 56 | 56 | exit(); | 
| 57 | 57 | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | -            }catch (Exception $e){ | |
| 60 | +            }catch (Exception $e) { | |
| 61 | 61 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); | 
| 62 | 62 | $output->writeln($e); | 
| 63 | 63 | sleep(300); | 
| @@ -67,25 +67,25 @@ discard block | ||
| 67 | 67 | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | -    protected function getFiles(){ | |
| 70 | +    protected function getFiles() { | |
| 71 | 71 |          $files = Upload::where('is_processed', '=', 3) | 
| 72 | -            ->where('is_email_sent','=',0) | |
| 72 | +            ->where('is_email_sent', '=', 0) | |
| 73 | 73 |              ->where('updated_at', '<=', Carbon::now()->tz('Asia/Colombo')->subHours(3)) | 
| 74 | 74 | ->limit(50) | 
| 75 | 75 | ->get()->toArray(); | 
| 76 | 76 | return $files; | 
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | -    protected function  process($file){ | |
| 79 | +    protected function  process($file) { | |
| 80 | 80 |          $time = Carbon::now()->tz('Asia/Colombo'); | 
| 81 | 81 | $this->processSheet($file); | 
| 82 | 82 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); | 
| 83 | 83 |          $now = Carbon::now()->tz('Asia/Colombo'); | 
| 84 | -        $output->writeln('=============== Time taken to batch ' .$now->diffInMinutes($time)); | |
| 84 | +        $output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time)); | |
| 85 | 85 | |
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | -    protected function processSheet($file){ | |
| 88 | +    protected function processSheet($file) { | |
| 89 | 89 |          $this->startTime = Carbon::now()->tz('Asia/Colombo'); | 
| 90 | 90 | $user = User::find($file['security_user_id']); | 
| 91 | 91 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); | 
| @@ -95,8 +95,8 @@ discard block | ||
| 95 | 95 | Mail::to($user->email)->send(new TerminatedReport($file)); | 
| 96 | 96 |              DB::table('uploads') | 
| 97 | 97 |                  ->where('id', $file['id']) | 
| 98 | - ->update(['is_processed' => 3, 'is_email_sent' => 1,'updated_at' => now()]); | |
| 99 | -        } else { | |
| 98 | + ->update(['is_processed' => 3, 'is_email_sent' => 1, 'updated_at' => now()]); | |
| 99 | +        }else { | |
| 100 | 100 | exit(); | 
| 101 | 101 | } | 
| 102 | 102 | } | 
| @@ -51,48 +51,48 @@ discard block | ||
| 51 | 51 |              'id' => $this->argument('institution') | 
| 52 | 52 | ])->first(); | 
| 53 | 53 | |
| 54 | -        if(!is_null($institution)){ | |
| 54 | +        if (!is_null($institution)) { | |
| 55 | 55 |              try { | 
| 56 | -                $this->info('adding missing students to the admission ' . $institution->name); | |
| 56 | +                $this->info('adding missing students to the admission '.$institution->name); | |
| 57 | 57 | $allApprovedStudents = Institution_student_admission::where([ | 
| 58 | 58 | 'status_id' => 124, | 
| 59 | 59 | 'institution_id' => $institution->id | 
| 60 | 60 | ])->get()->toArray(); | 
| 61 | 61 | $allApprovedStudents = array_chunk($allApprovedStudents, 50); | 
| 62 | 62 | array_walk($allApprovedStudents, array($this, 'addStudents')); | 
| 63 | -            } catch (\Exception $e) { | |
| 63 | +            }catch (\Exception $e) { | |
| 64 | 64 | Log::error($e); | 
| 65 | 65 | } | 
| 66 | 66 | } | 
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | -    protected function addStudents($students){ | |
| 70 | - array_walk($students,array($this,'addStudent')); | |
| 69 | +    protected function addStudents($students) { | |
| 70 | + array_walk($students, array($this, 'addStudent')); | |
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | -    protected function addStudent($student){ | |
| 73 | +    protected function addStudent($student) { | |
| 74 | 74 | // dd(Institution_class_student::isDuplicated($student)); | 
| 75 | 75 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); | 
| 76 | 76 | sleep(1); | 
| 77 | -        if(!(Institution_class_student::isDuplicated($student) > 0)){ | |
| 77 | +        if (!(Institution_class_student::isDuplicated($student) > 0)) { | |
| 78 | 78 | $this->count += 1; | 
| 79 | - $this->student = $student ; | |
| 80 | -            try{ | |
| 79 | + $this->student = $student; | |
| 80 | +            try { | |
| 81 | 81 | Institution_student::create([ | 
| 82 | 82 | 'student_status_id' => 1, | 
| 83 | 83 | 'student_id' => $student['student_id'], | 
| 84 | 84 | 'education_grade_id' => $student['education_grade_id'], | 
| 85 | 85 | 'academic_period_id' => $student['academic_period_id'], | 
| 86 | 86 | 'start_date' => $student['start_date'], | 
| 87 | -                   'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['start_date'])->year , // $student['start_date']->format('Y'), | |
| 87 | +                   'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['start_date'])->year, // $student['start_date']->format('Y'), | |
| 88 | 88 | 'end_date' => $student['end_date'], | 
| 89 | -                   'end_year' =>  \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['end_date'])->year , //$student['end_date']->format('Y'), | |
| 89 | +                   'end_year' =>  \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $student['end_date'])->year, //$student['end_date']->format('Y'), | |
| 90 | 90 | 'institution_id' => $student['institution_id'], | 
| 91 | 91 | 'admission_id' => $student['admission_id'], | 
| 92 | 92 | 'created_user_id' => $student['created_user_id'], | 
| 93 | 93 | ]); | 
| 94 | 94 | |
| 95 | -               if(!is_null($student['institution_class_id'])){ | |
| 95 | +               if (!is_null($student['institution_class_id'])) { | |
| 96 | 96 | Institution_class_student::create([ | 
| 97 | 97 | 'student_id' => $student['student_id'], | 
| 98 | 98 | 'institution_class_id' => $student['institution_class_id'], | 
| @@ -109,23 +109,23 @@ discard block | ||
| 109 | 109 | # # | 
| 110 | 110 | ####################################################' ); | 
| 111 | 111 | // $output->writeln(); | 
| 112 | -           }catch (\Exception $e){ | |
| 112 | +           }catch (\Exception $e) { | |
| 113 | 113 | // echo $e->getMessage(); | 
| 114 | - $output->writeln( $e->getMessage()); | |
| 114 | + $output->writeln($e->getMessage()); | |
| 115 | 115 | } | 
| 116 | 116 | } | 
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | 119 | |
| 120 | -    protected  function  setSubjects($student){ | |
| 120 | +    protected  function  setSubjects($student) { | |
| 121 | 121 | $allSubjects = Institution_class_subject::getMandetorySubjects($student['institution_class_id']); | 
| 122 | 122 | |
| 123 | 123 |          if (!empty($allSubjects)) { | 
| 124 | 124 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); | 
| 125 | 125 | $this->student = $student; | 
| 126 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); | |
| 126 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); | |
| 127 | 127 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); | 
| 128 | - array_walk($allSubjects,array($this,'insertSubject')); | |
| 128 | + array_walk($allSubjects, array($this, 'insertSubject')); | |
| 129 | 129 | } | 
| 130 | 130 | |
| 131 | 131 | unset($allSubjects); | 
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 | } | 
| 134 | 134 | |
| 135 | 135 | |
| 136 | -    protected function setStudentSubjects($subject){ | |
| 136 | +    protected function setStudentSubjects($subject) { | |
| 137 | 137 | return [ | 
| 138 | 138 | 'id' => (string) Uuid::generate(4), | 
| 139 | 139 | 'student_id' => $this->student->student_id, | 
| @@ -149,8 +149,8 @@ discard block | ||
| 149 | 149 | ]; | 
| 150 | 150 | } | 
| 151 | 151 | |
| 152 | -    protected function insertSubject($subject){ | |
| 153 | -        if(!Institution_subject_student::isDuplicated($subject)){ | |
| 152 | +    protected function insertSubject($subject) { | |
| 153 | +        if (!Institution_subject_student::isDuplicated($subject)) { | |
| 154 | 154 | Institution_subject_student::updateOrInsert($subject); | 
| 155 | 155 | } | 
| 156 | 156 | } | 
| @@ -39,17 +39,17 @@ | ||
| 39 | 39 | */ | 
| 40 | 40 | public function handle() | 
| 41 | 41 |      { | 
| 42 | -        ini_set('memory_limit','2048'); | |
| 42 | +        ini_set('memory_limit', '2048'); | |
| 43 | 43 | $institutions = $this->instituions->all()->chunk(50)->toArray(); | 
| 44 | - array_walk($institutions,array($this,'addInstitutionStudents')); | |
| 44 | + array_walk($institutions, array($this, 'addInstitutionStudents')); | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | -    protected function addInstitutionStudents($chunk){ | |
| 48 | - array_walk($chunk,array($this,'callFunction')); | |
| 47 | +    protected function addInstitutionStudents($chunk) { | |
| 48 | + array_walk($chunk, array($this, 'callFunction')); | |
| 49 | 49 | |
| 50 | 50 | } | 
| 51 | 51 | |
| 52 | -    protected function callFunction($institution){ | |
| 53 | -        $this->call('admission:students',['institution' => $institution['code']]); | |
| 52 | +    protected function callFunction($institution) { | |
| 53 | +        $this->call('admission:students', ['institution' => $institution['code']]); | |
| 54 | 54 | } | 
| 55 | 55 | } | 
| @@ -31,12 +31,12 @@ discard block | ||
| 31 | 31 |      public function __construct($class) { | 
| 32 | 32 | |
| 33 | 33 | $this->class = $class; | 
| 34 | - $this->_file_name = time() . '_' . Auth::user()->id . '_' . 'student_upload.xls'; | |
| 34 | + $this->_file_name = time().'_'.Auth::user()->id.'_'.'student_upload.xls'; | |
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | 37 |      public function registerEvents(): array { | 
| 38 | 38 | return [ | 
| 39 | -        BeforeSheet::class => function(BeforeSheet $event){ | |
| 39 | +        BeforeSheet::class => function(BeforeSheet $event) { | |
| 40 | 40 | // dd($event->crea) | 
| 41 | 41 | }, | 
| 42 | 42 |              BeforeWriting::class => function(BeforeWriting $event) { | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | $class = $this->class; | 
| 64 | 64 |          return Security_user::select('openemis_no', 'first_name', 'gender_id', 'date_of_birth', 'address', 'birthplace_area_id') | 
| 65 | 65 | ->with(['class', 'special_needs']) | 
| 66 | -                        ->whereHas('class', function ($query) use ($class) { | |
| 66 | +                        ->whereHas('class', function($query) use ($class) { | |
| 67 | 67 |                              $query->where('institution_class_id', '=', $class); | 
| 68 | 68 | }) | 
| 69 | 69 | ->get(); |