@@ -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; |
@@ -18,10 +18,10 @@ |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * @param array $row |
|
22 | - * |
|
23 | - * @return \Illuminate\Database\Eloquent\Model|null |
|
24 | - */ |
|
21 | + * @param array $row |
|
22 | + * |
|
23 | + * @return \Illuminate\Database\Eloquent\Model|null |
|
24 | + */ |
|
25 | 25 | |
26 | 26 | public function sheets(): array |
27 | 27 | { |
@@ -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 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | public function boot() { |
13 | 13 | $this->app->validator->resolver( function( $translator, $data, $rules, |
14 | - $messages = array(), $customAttributes = array() ) { |
|
14 | + $messages = array(), $customAttributes = array() ) { |
|
15 | 15 | return new ValidatorExtended( $translator, $data, $rules, $messages, |
16 | 16 | $customAttributes ); |
17 | 17 | } ); |
@@ -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 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | protected function mapWebRoutes() |
53 | 53 | { |
54 | 54 | Route::middleware('web') |
55 | - ->namespace($this->namespace) |
|
56 | - ->group(base_path('routes/web.php')); |
|
55 | + ->namespace($this->namespace) |
|
56 | + ->group(base_path('routes/web.php')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | protected function mapApiRoutes() |
67 | 67 | { |
68 | 68 | Route::prefix('api') |
69 | - ->middleware('api') |
|
70 | - ->namespace($this->namespace) |
|
71 | - ->group(base_path('routes/api.php')); |
|
69 | + ->middleware('api') |
|
70 | + ->namespace($this->namespace) |
|
71 | + ->group(base_path('routes/api.php')); |
|
72 | 72 | } |
73 | 73 | } |
@@ -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 | } |
@@ -50,14 +50,14 @@ |
||
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); |
@@ -78,41 +78,41 @@ |
||
78 | 78 | $this->count += 1; |
79 | 79 | $this->student = $student ; |
80 | 80 | try{ |
81 | - Institution_student::create([ |
|
82 | - 'student_status_id' => 1, |
|
83 | - 'student_id' => $student['student_id'], |
|
84 | - 'education_grade_id' => $student['education_grade_id'], |
|
85 | - 'academic_period_id' => $student['academic_period_id'], |
|
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'), |
|
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'), |
|
90 | - 'institution_id' => $student['institution_id'], |
|
91 | - 'admission_id' => $student['admission_id'], |
|
92 | - 'created_user_id' => $student['created_user_id'], |
|
93 | - ]); |
|
94 | - |
|
95 | - if(!is_null($student['institution_class_id'])){ |
|
96 | - Institution_class_student::create([ |
|
97 | - 'student_id' => $student['student_id'], |
|
98 | - 'institution_class_id' => $student['institution_class_id'], |
|
99 | - 'education_grade_id' => $student['education_grade_id'], |
|
100 | - 'academic_period_id' => $student['academic_period_id'], |
|
101 | - 'institution_id' =>$student['institution_id'], |
|
102 | - 'student_status_id' => 1, |
|
103 | - 'created_user_id' => $student['created_user_id'], |
|
104 | - ]); |
|
105 | - } |
|
81 | + Institution_student::create([ |
|
82 | + 'student_status_id' => 1, |
|
83 | + 'student_id' => $student['student_id'], |
|
84 | + 'education_grade_id' => $student['education_grade_id'], |
|
85 | + 'academic_period_id' => $student['academic_period_id'], |
|
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'), |
|
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'), |
|
90 | + 'institution_id' => $student['institution_id'], |
|
91 | + 'admission_id' => $student['admission_id'], |
|
92 | + 'created_user_id' => $student['created_user_id'], |
|
93 | + ]); |
|
94 | + |
|
95 | + if(!is_null($student['institution_class_id'])){ |
|
96 | + Institution_class_student::create([ |
|
97 | + 'student_id' => $student['student_id'], |
|
98 | + 'institution_class_id' => $student['institution_class_id'], |
|
99 | + 'education_grade_id' => $student['education_grade_id'], |
|
100 | + 'academic_period_id' => $student['academic_period_id'], |
|
101 | + 'institution_id' =>$student['institution_id'], |
|
102 | + 'student_status_id' => 1, |
|
103 | + 'created_user_id' => $student['created_user_id'], |
|
104 | + ]); |
|
105 | + } |
|
106 | 106 | $output->writeln(' |
107 | 107 | #################################################### |
108 | 108 | Total number of students updated : '.$this->count.' |
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()); |
|
115 | - } |
|
114 | + $output->writeln( $e->getMessage()); |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 |
@@ -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 | } |
@@ -109,7 +109,7 @@ |
||
109 | 109 | # # |
110 | 110 | ####################################################' ); |
111 | 111 | // $output->writeln(); |
112 | - }catch (\Exception $e){ |
|
112 | + } catch (\Exception $e){ |
|
113 | 113 | // echo $e->getMessage(); |
114 | 114 | $output->writeln( $e->getMessage()); |
115 | 115 | } |
@@ -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 | } |