@@ -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 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function boot() |
| 29 | 29 | { |
| 30 | 30 | // |
| 31 | - if((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { |
|
| 31 | + if ((\App::environment('dev')) | (\App::environment('stage')) | (\App::environment('prod'))) { |
|
| 32 | 32 | URL::forceScheme('https'); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -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 | } |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | $this->start_time = microtime(TRUE); |
| 47 | 47 | ini_set('memory_limit', '2048M'); |
| 48 | 48 | $students = $this->students->query() |
| 49 | - ->where('is_student',1) |
|
| 49 | + ->where('is_student', 1) |
|
| 50 | 50 | ->limit(100000) |
| 51 | 51 | ->offset($this->argument('offset')) |
| 52 | 52 | ->get()->toArray(); |
| 53 | 53 | $this->output->writeln('no of students'.count($students)); |
| 54 | 54 | $this->output->writeln('Update started'); |
| 55 | - array_walk($students,array($this,'updateNewUUID')); |
|
| 55 | + array_walk($students, array($this, 'updateNewUUID')); |
|
| 56 | 56 | $this->end_time = microtime(TRUE); |
| 57 | 57 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
| 58 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
| 58 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
| 59 | 59 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | * @param $student |
| 65 | 65 | * @throws \Exception |
| 66 | 66 | */ |
| 67 | - public function updateNewUUID($student){ |
|
| 68 | - if(!MoeUuid::isValidMoeUuid(3)){ |
|
| 67 | + public function updateNewUUID($student) { |
|
| 68 | + if (!MoeUuid::isValidMoeUuid(3)) { |
|
| 69 | 69 | $newId = MoeUuid::getUniqueAlphanumeric(3); |
| 70 | 70 | $this->output->writeln('Updating student:'.$student['id']); |
| 71 | - Security_user::query()->where('id',$student['id']) |
|
| 72 | - ->update(['openemis_no' => $newId , 'username' => str_replace('-','',$newId)]); |
|
| 71 | + Security_user::query()->where('id', $student['id']) |
|
| 72 | + ->update(['openemis_no' => $newId, 'username' => str_replace('-', '', $newId)]); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -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 | } |