@@ -65,15 +65,15 @@ |
||
65 | 65 | $institution = $this->argument('institution'); |
66 | 66 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
67 | 67 | $previousAcademicPeriodYear = $academicPeriod->order; |
68 | - $previousAcademicPeriod = Academic_period::where('order',$previousAcademicPeriodYear+1)->first(); |
|
68 | + $previousAcademicPeriod = Academic_period::where('order', $previousAcademicPeriodYear + 1)->first(); |
|
69 | 69 | $mode = $this->argument('mode'); |
70 | - $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($previousAcademicPeriod->code,$institution,$mode); |
|
70 | + $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($previousAcademicPeriod->code, $institution, $mode); |
|
71 | 71 | $output->writeln('Start promoting:'.$institution); |
72 | 72 | $params = [ |
73 | 73 | 'academicPeriod' => $academicPeriod, |
74 | 74 | 'previousAcademicPeriod' => $previousAcademicPeriod |
75 | 75 | ]; |
76 | - (new BulkPromotion())->callback($institutionGrade,$params); |
|
76 | + (new BulkPromotion())->callback($institutionGrade, $params); |
|
77 | 77 | $output->writeln('Finished promoting:'.$institution); |
78 | 78 | } |
79 | 79 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Education_grades_subject extends Model { |
|
7 | +class Education_grades_subject extends Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | protected $dates = ['modified', 'created']; |
43 | 43 | |
44 | 44 | |
45 | - public function institutionGradeSubject(){ |
|
46 | - return $this->hasMany('App\Models\Institution_subject','education_grade_id','education_grade_id'); |
|
45 | + public function institutionGradeSubject() { |
|
46 | + return $this->hasMany('App\Models\Institution_subject', 'education_grade_id', 'education_grade_id'); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function getGradeSubjects($educationGrade){ |
|
50 | - self::where('education_grade_id',$educationGrade['education_grade_id']) |
|
49 | + public function getGradeSubjects($educationGrade) { |
|
50 | + self::where('education_grade_id', $educationGrade['education_grade_id']) |
|
51 | 51 | ->get() |
52 | 52 | ->toArray(); |
53 | 53 | ; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Institution_subject extends Base_Model { |
|
7 | +class Institution_subject extends Base_Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -42,29 +42,29 @@ discard block |
||
42 | 42 | protected $dates = ['modified', 'created', 'modified', 'created']; |
43 | 43 | |
44 | 44 | |
45 | - public function institutionGradeSubject(){ |
|
46 | - return $this->belongsTo('App\Models\Education_grades_subject','education_subject_id','education_subject_id'); |
|
45 | + public function institutionGradeSubject() { |
|
46 | + return $this->belongsTo('App\Models\Education_grades_subject', 'education_subject_id', 'education_subject_id'); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function institutionOptionalGradeSubject(){ |
|
50 | - return $this->belongsTo('App\Models\Education_grades_subject','education_grade_id','education_grade_id'); |
|
49 | + public function institutionOptionalGradeSubject() { |
|
50 | + return $this->belongsTo('App\Models\Education_grades_subject', 'education_grade_id', 'education_grade_id'); |
|
51 | 51 | } |
52 | 52 | |
53 | - public function institutionMandatoryGradeSubject(){ |
|
54 | - return $this->belongsTo('App\Models\Education_grades_subject','education_grade_id','education_grade_id'); |
|
53 | + public function institutionMandatoryGradeSubject() { |
|
54 | + return $this->belongsTo('App\Models\Education_grades_subject', 'education_grade_id', 'education_grade_id'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | - public function institutionClassSubject(){ |
|
59 | - return $this->hasMany('App\Models\Institution_class_subject','institution_class_id','id'); |
|
58 | + public function institutionClassSubject() { |
|
59 | + return $this->hasMany('App\Models\Institution_class_subject', 'institution_class_id', 'id'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | - public function getInstitutionSubjects($institution_id,$academic_period_id){ |
|
65 | - $query = self::query()->where('institution_id',$institution_id) |
|
66 | - ->where('academic_period_id',$academic_period_id) |
|
67 | - ->join('education_grades_subjects','institution_subjects.education_subject_id','education_grades_subjects.id') |
|
64 | + public function getInstitutionSubjects($institution_id, $academic_period_id) { |
|
65 | + $query = self::query()->where('institution_id', $institution_id) |
|
66 | + ->where('academic_period_id', $academic_period_id) |
|
67 | + ->join('education_grades_subjects', 'institution_subjects.education_subject_id', 'education_grades_subjects.id') |
|
68 | 68 | ->join('education_grades', 'education_grades_subjects.education_grade_id', 'education_grades.id') |
69 | 69 | ->groupBy('education_grades_subjects.id'); |
70 | 70 | return $query->get()->toArray(); |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | |
73 | 73 | public static function getStudentsCount($institution_subject_id) |
74 | 74 | { |
75 | - $total_male_students = self::with(['student' => function ($query) { |
|
75 | + $total_male_students = self::with(['student' => function($query) { |
|
76 | 76 | $query->where('student.gender_id', '=', 1); |
77 | - }])->whereHas('student', function ($query) { |
|
77 | + }])->whereHas('student', function($query) { |
|
78 | 78 | $query->where('gender_id', '=', 1); |
79 | 79 | })->where('institution_subject_id', '=', $institution_subject_id)->count(); |
80 | 80 | |
81 | - $total_female_students = self::with(['student' => function ($query) { |
|
81 | + $total_female_students = self::with(['student' => function($query) { |
|
82 | 82 | $query->where('student.gender_id', '=', 2); |
83 | - }])->whereHas('student', function ($query) { |
|
83 | + }])->whereHas('student', function($query) { |
|
84 | 84 | $query->where('gender_id', '=', 2); |
85 | 85 | })->where('institution_subject_id', '=', $institution_subject_id)->count(); |
86 | 86 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Education_grade extends Model { |
|
7 | +class Education_grade extends Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $dates = ['modified', 'created']; |
43 | 43 | |
44 | - public function getNextGrade($gradeId,$getNextProgrammeGrades = false, $firstGradeOnly = false){ |
|
44 | + public function getNextGrade($gradeId, $getNextProgrammeGrades = false, $firstGradeOnly = false) { |
|
45 | 45 | if (!empty($gradeId)) { |
46 | 46 | $gradeObj = $this->find($gradeId); |
47 | 47 | $programmeId = $gradeObj->education_programme_id; |
48 | 48 | $order = $gradeObj->order; |
49 | - $gradeOptions = self::where( 'education_programme_id',$programmeId |
|
50 | - )->where('order',$order+1)->get()->first(); |
|
49 | + $gradeOptions = self::where('education_programme_id', $programmeId |
|
50 | + )->where('order', $order + 1)->get()->first(); |
|
51 | 51 | $nextProgramme = self::getNextProgrammeList($programmeId); |
52 | - if(is_null($gradeOptions) && !is_null($nextProgramme)){ |
|
53 | - $programmeId = $nextProgramme->next_programme_id; |
|
54 | - $gradeOptions = self::where( 'education_programme_id',$programmeId |
|
52 | + if (is_null($gradeOptions) && !is_null($nextProgramme)) { |
|
53 | + $programmeId = $nextProgramme->next_programme_id; |
|
54 | + $gradeOptions = self::where('education_programme_id', $programmeId |
|
55 | 55 | ) |
56 | 56 | ->orderBy('order') |
57 | 57 | ->get()->first(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | // $results = $gradeOptions; |
69 | 69 | // } |
70 | 70 | return $gradeOptions; |
71 | - } else { |
|
71 | + }else { |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 | } |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | |
81 | 81 | foreach ($nextProgrammeList as $nextProgrammeId) { |
82 | 82 | $nextProgrammeGradeResults = self:: |
83 | - where('education_programme_id',$nextProgrammeId->next_programme_id)->get()->toArray(); |
|
83 | + where('education_programme_id', $nextProgrammeId->next_programme_id)->get()->toArray(); |
|
84 | 84 | |
85 | 85 | $results = $results + [key($nextProgrammeGradeResults) => current($nextProgrammeGradeResults)]; |
86 | 86 | } |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | $results = []; |
89 | 89 | } |
90 | 90 | |
91 | - return (object)$results; |
|
91 | + return (object) $results; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | |
103 | 103 | $nextProgrammeList = $this->getNextProgrammeList($id); |
104 | 104 | if (!empty($nextProgrammeList)) { |
105 | - $results = self::whereIn('education_programme_id',$nextProgrammeList) |
|
105 | + $results = self::whereIn('education_programme_id', $nextProgrammeList) |
|
106 | 106 | ->get()->toArray(); |
107 | - } else { |
|
107 | + }else { |
|
108 | 108 | $results = []; |
109 | 109 | } |
110 | 110 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return array List of next education programmes id |
119 | 119 | */ |
120 | 120 | public function getNextProgrammeList($id) { |
121 | - return Education_programmes_next_programme::where('education_programme_id',$id) |
|
121 | + return Education_programmes_next_programme::where('education_programme_id', $id) |
|
122 | 122 | ->get()->first(); |
123 | 123 | } |
124 | 124 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public static function boot() |
59 | 59 | { |
60 | 60 | parent::boot(); |
61 | - self::creating(function ($model) { |
|
61 | + self::creating(function($model) { |
|
62 | 62 | $model->id = (string) Uuid::generate(4); |
63 | 63 | $model->created = now(); |
64 | 64 | }); |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function getStudentsCount($institution_class_id) |
73 | 73 | { |
74 | - $total_male_students = self::with(['student' => function ($query) { |
|
74 | + $total_male_students = self::with(['student' => function($query) { |
|
75 | 75 | $query->where('student.gender_id', '=', 1); |
76 | - }])->whereHas('student', function ($query) { |
|
76 | + }])->whereHas('student', function($query) { |
|
77 | 77 | $query->where('gender_id', '=', 1); |
78 | 78 | })->where('institution_class_id', '=', $institution_class_id)->count(); |
79 | 79 | |
80 | - $total_female_students = self::with(['student' => function ($query) { |
|
80 | + $total_female_students = self::with(['student' => function($query) { |
|
81 | 81 | $query->where('student.gender_id', '=', 2); |
82 | - }])->whereHas('student', function ($query) { |
|
82 | + }])->whereHas('student', function($query) { |
|
83 | 83 | $query->where('gender_id', '=', 2); |
84 | 84 | })->where('institution_class_id', '=', $institution_class_id)->count(); |
85 | 85 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | ->where('student_id', $student['student_id']) |
110 | 110 | ->join('institution_classes', 'institution_class_students.institution_class_id', '=', 'institution_classes.id') |
111 | 111 | ->where('institution_class_students.student_id', $student['student_id']) |
112 | - ->where('institution_class_students.academic_period_id',$student['academic_period_id']) |
|
113 | - ->where('institution_class_students.institution_id',$student['institution_id']) |
|
112 | + ->where('institution_class_students.academic_period_id', $student['academic_period_id']) |
|
113 | + ->where('institution_class_students.institution_id', $student['institution_id']) |
|
114 | 114 | ->whereNull('institution_class_students.deleted_at') |
115 | 115 | ->get()->first(); |
116 | 116 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'institution_id' => $admissionInfo['instituion']->id, |
135 | 135 | 'student_status_id' => 1 |
136 | 136 | ]); |
137 | - } catch (\Throwable $th) { |
|
137 | + }catch (\Throwable $th) { |
|
138 | 138 | Log::error($th); |
139 | 139 | } |
140 | 140 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | use Webpatser\Uuid\Uuid; |
7 | 7 | |
8 | -class Institution_class_subject extends Base_Model { |
|
8 | +class Institution_class_subject extends Base_Model { |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * The database table used by the model. |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected $dates = ['modified', 'created']; |
44 | 44 | |
45 | - public function institutionMandatorySubject(){ |
|
46 | - return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id') |
|
45 | + public function institutionMandatorySubject() { |
|
46 | + return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id') |
|
47 | 47 | ->with('institutionGradeSubject') |
48 | - ->whereHas('institutionGradeSubject', function ($query) { |
|
49 | - $query->where('auto_allocation',1); |
|
48 | + ->whereHas('institutionGradeSubject', function($query) { |
|
49 | + $query->where('auto_allocation', 1); |
|
50 | 50 | }); |
51 | 51 | } |
52 | 52 | |
53 | - public function institutionOptionalSubject(){ |
|
54 | - return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id') |
|
53 | + public function institutionOptionalSubject() { |
|
54 | + return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id') |
|
55 | 55 | ->with('institutionGradeSubject') |
56 | - ->whereHas('institutionGradeSubject', function ($query) { |
|
57 | - $query->where('auto_allocation',0); |
|
56 | + ->whereHas('institutionGradeSubject', function($query) { |
|
57 | + $query->where('auto_allocation', 0); |
|
58 | 58 | }); |
59 | 59 | |
60 | 60 | } |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | public static function boot() |
63 | 63 | { |
64 | 64 | parent::boot(); |
65 | - self::creating(function ($model) { |
|
65 | + self::creating(function($model) { |
|
66 | 66 | $model->id = (string) Uuid::generate(4); |
67 | 67 | }); |
68 | 68 | } |
69 | 69 | |
70 | - public function institutionSubject(){ |
|
71 | - return $this->belongsTo('App\Models\Institution_subject','institution_subject_id','id') |
|
70 | + public function institutionSubject() { |
|
71 | + return $this->belongsTo('App\Models\Institution_subject', 'institution_subject_id', 'id') |
|
72 | 72 | ->with('institutionGradeSubject'); |
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | - public static function getMandetorySubjects($institutionClass){ |
|
76 | + public static function getMandetorySubjects($institutionClass) { |
|
77 | 77 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass)->first(); |
78 | 78 | $mandatorySubject = Institution_class_subject::with(['institutionSubject']) |
79 | - ->whereHas('institutionSubject', function ($query) use ($institutionGrade) { |
|
80 | - $query->whereHas('institutionGradeSubject',function($query){ |
|
81 | - $query->where('auto_allocation',1); |
|
79 | + ->whereHas('institutionSubject', function($query) use ($institutionGrade) { |
|
80 | + $query->whereHas('institutionGradeSubject', function($query) { |
|
81 | + $query->where('auto_allocation', 1); |
|
82 | 82 | })->where('education_grade_id', $institutionGrade->education_grade_id); |
83 | 83 | // ->where('auto_allocation', $institutionGrade->education_grade_id); |
84 | 84 | }) |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | return $mandatorySubject; |
88 | 88 | } |
89 | 89 | |
90 | - public static function getAllSubjects($institutionClass){ |
|
90 | + public static function getAllSubjects($institutionClass) { |
|
91 | 91 | $allSubjects = Institution_class_subject::with(['institutionSubject']) |
92 | - ->whereHas('institutionSubject', function ($query) use ($institutionClass) { |
|
92 | + ->whereHas('institutionSubject', function($query) use ($institutionClass) { |
|
93 | 93 | $query->whereHas('institutionGradeSubject')->where('education_grade_id', $institutionClass['education_grade_id']); |
94 | 94 | }) |
95 | 95 | ->where('institution_class_id', '=', $institutionClass['id']) |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | $data = []; |
102 | 102 | foreach ($subjects as $subject) { |
103 | 103 | $subjectId = Institution_class_subject::with(['institutionSubject']) |
104 | - ->whereHas('institutionSubject', function ($query) use ($row, $subject, $student) { |
|
105 | - $query->whereHas('institutionGradeSubject',function($query){ |
|
106 | - $query->where('auto_allocation',0); |
|
104 | + ->whereHas('institutionSubject', function($query) use ($row, $subject, $student) { |
|
105 | + $query->whereHas('institutionGradeSubject', function($query) { |
|
106 | + $query->where('auto_allocation', 0); |
|
107 | 107 | }) |
108 | 108 | ->where('name', '=', $row[$subject]) |
109 | 109 | ->where('education_grade_id', '=', $student->education_grade_id); |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | return $data; |
117 | 117 | } |
118 | 118 | |
119 | - public function getInstitutionClassSubjects($academicPeriodId,$classIds){ |
|
119 | + public function getInstitutionClassSubjects($academicPeriodId, $classIds) { |
|
120 | 120 | return self::query() |
121 | - ->whereIn('institution_class_id',$classIds) |
|
121 | + ->whereIn('institution_class_id', $classIds) |
|
122 | 122 | ->get() |
123 | 123 | ->toArray(); |
124 | 124 | } |
125 | 125 | |
126 | - public function isDuplicated($subject){ |
|
127 | - return self::query()->where('institution_subject_id',$subject['institution_subject_id']) |
|
128 | - ->where('institution_class_id',$subject['institution_class_id'])->get()->toArray(); |
|
126 | + public function isDuplicated($subject) { |
|
127 | + return self::query()->where('institution_subject_id', $subject['institution_subject_id']) |
|
128 | + ->where('institution_class_id', $subject['institution_class_id'])->get()->toArray(); |
|
129 | 129 | } |
130 | 130 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | |
52 | 52 | if ($this->argument('code') !== 'All') { |
53 | 53 | $institutions = Institution::where('code', $this->argument('code'))->get()->toArray(); |
54 | - processParallel(array($this,'processInstitution'),$institutions,$this->argument('max')); |
|
55 | - } else { |
|
54 | + processParallel(array($this, 'processInstitution'), $institutions, $this->argument('max')); |
|
55 | + }else { |
|
56 | 56 | $institutions = Institution::where('institution_status_id', 1)->get()->toArray(); |
57 | - processParallel(array($this,'processInstitution'),$institutions,$this->argument('max')); |
|
57 | + processParallel(array($this, 'processInstitution'), $institutions, $this->argument('max')); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | ->where('institutions.id', $institution['id']) |
66 | 66 | ->get()->toArray(); |
67 | 67 | if (count($students) > 0) { |
68 | - array_walk($students,array($this, 'process')); |
|
69 | - $this->output->writeln("institution :" .$institution['code']. ' cleaned'); |
|
70 | - } else { |
|
71 | - $this->output->writeln("all records are cleaned at :".$institution['code'] ); |
|
68 | + array_walk($students, array($this, 'process')); |
|
69 | + $this->output->writeln("institution :".$institution['code'].' cleaned'); |
|
70 | + }else { |
|
71 | + $this->output->writeln("all records are cleaned at :".$institution['code']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function process($student) |
76 | 76 | { |
77 | - try{ |
|
77 | + try { |
|
78 | 78 | $wrongStudentsClass = Institution_class_student::where('institution_id', $student['institution_id']) |
79 | 79 | ->whereRaw('institution_class_id not in (select id from institution_classes where institution_id ='.$student['institution_id'].' )') |
80 | 80 | ->orWhere('institution_class_id', 0) |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | array_walk($wrongStudentsClass, array($this->class, 'updateClassCount')); |
90 | 90 | |
91 | - $institutionClass = Institution_class::getGradeClasses($student['education_grade_id'], $student['institution_id']); |
|
91 | + $institutionClass = Institution_class::getGradeClasses($student['education_grade_id'], $student['institution_id']); |
|
92 | 92 | |
93 | 93 | if (count($institutionClass) == 1) { |
94 | 94 | $start_date = new Carbon($student['start_date']); |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | ]); |
141 | 141 | $institutionClassStudent = [$institutionClassStudent]; |
142 | 142 | array_walk($institutionClassStudent, array($this->class, 'updateClassCount')); |
143 | - $this->output->writeln("student record :".$student['student_id'] ); |
|
143 | + $this->output->writeln("student record :".$student['student_id']); |
|
144 | 144 | } |
145 | 145 | } |
146 | - }catch(\Exception $e){ |
|
146 | + }catch (\Exception $e) { |
|
147 | 147 | dd($e); |
148 | 148 | } |
149 | 149 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public static function boot() |
72 | 72 | { |
73 | 73 | parent::boot(); |
74 | - self::creating(function ($model) { |
|
74 | + self::creating(function($model) { |
|
75 | 75 | $model->id = (string) Uuid::generate(4); |
76 | 76 | $model->created = now(); |
77 | 77 | }); |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | 'institution_students.admission_id' |
130 | 130 | ) |
131 | 131 | ->where('institution_students.institution_id', $institutionGrade['institution_id']) |
132 | - ->where('institution_students.student_status_id',1) |
|
132 | + ->where('institution_students.student_status_id', 1) |
|
133 | 133 | ->where('institution_students.education_grade_id', $institutionGrade['education_grade_id']) |
134 | - ->where('institution_students.deleted_at',null) |
|
134 | + ->where('institution_students.deleted_at', null) |
|
135 | 135 | ->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray(); |
136 | 136 | } |
137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public static function createExaminationData($student, $admissionInfo) |
146 | 146 | { |
147 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
147 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
148 | 148 | try { |
149 | 149 | self::create([ |
150 | 150 | 'id' => (string) Uuid::generate(4), |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | 'created' => now(), |
170 | 170 | 'created_user_id' => 1 |
171 | 171 | ]); |
172 | - } catch (\Throwable $th) { |
|
172 | + }catch (\Throwable $th) { |
|
173 | 173 | Log::error($th); |
174 | 174 | } |
175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public static function updateExaminationData($student, $admissionInfo) |
185 | 185 | { |
186 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
186 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
187 | 187 | try { |
188 | 188 | self::where([ |
189 | 189 | 'student_id' => $student['student_id'], |
@@ -204,50 +204,50 @@ discard block |
||
204 | 204 | 'modified_user_id' => 1 |
205 | 205 | ] |
206 | 206 | ); |
207 | - } catch (\Throwable $th) { |
|
207 | + }catch (\Throwable $th) { |
|
208 | 208 | Log::error($th); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - public static function updateStudentArea(array $student){ |
|
213 | - $father = Student_guardian::where('student_id',$student['student_id']) |
|
214 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
215 | - ->where('guardian_relation_id',1) |
|
212 | + public static function updateStudentArea(array $student) { |
|
213 | + $father = Student_guardian::where('student_id', $student['student_id']) |
|
214 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
215 | + ->where('guardian_relation_id', 1) |
|
216 | 216 | ->get()->first(); |
217 | 217 | |
218 | - $mother = Student_guardian::where('student_id',$student['student_id']) |
|
219 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
220 | - ->where('guardian_relation_id',2) |
|
218 | + $mother = Student_guardian::where('student_id', $student['student_id']) |
|
219 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
220 | + ->where('guardian_relation_id', 2) |
|
221 | 221 | ->get()->first(); |
222 | 222 | |
223 | - $guardian = Student_guardian::where('student_id',$student['student_id']) |
|
224 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
225 | - ->where('guardian_relation_id',3) |
|
223 | + $guardian = Student_guardian::where('student_id', $student['student_id']) |
|
224 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
225 | + ->where('guardian_relation_id', 3) |
|
226 | 226 | ->get()->first(); |
227 | 227 | |
228 | - if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
|
229 | - Security_user::where('id',$student['student_id']) |
|
228 | + if (!is_null($father) && is_null($mother) && is_null($guardian)) { |
|
229 | + Security_user::where('id', $student['student_id']) |
|
230 | 230 | ->update(['address_area_id' => $father->address_area_id]); |
231 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
232 | - Security_user::where('id',$student['student_id']) |
|
231 | + }elseif (!is_null($mother) && (is_null($father) && is_null($guardian))) { |
|
232 | + Security_user::where('id', $student['student_id']) |
|
233 | 233 | ->update(['address_area_id' => $mother->address_area_id]); |
234 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
235 | - Security_user::where('id',$student['student_id']) |
|
234 | + }elseif (!is_null($guardian) && is_null($father) && is_null($mother)) { |
|
235 | + Security_user::where('id', $student['student_id']) |
|
236 | 236 | ->update(['address_area_id' => $guardian->address_area_id]); |
237 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
238 | - Security_user::where('id',$student['student_id']) |
|
237 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) { |
|
238 | + Security_user::where('id', $student['student_id']) |
|
239 | 239 | ->update(['address_area_id' => $mother->address_area_id]); |
240 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
241 | - Security_user::where('id',$student['student_id']) |
|
240 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) { |
|
241 | + Security_user::where('id', $student['student_id']) |
|
242 | 242 | ->update(['address_area_id' => $guardian->address_area_id]); |
243 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
244 | - Security_user::where('id',$student['student_id']) |
|
243 | + }elseif (!is_null($father) && $father->address == $student['address']) { |
|
244 | + Security_user::where('id', $student['student_id']) |
|
245 | 245 | ->update(['address_area_id' => $guardian->address_area_id]); |
246 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
247 | - Security_user::where('id',$student['student_id']) |
|
246 | + }elseif (!is_null($mother) && $mother->address == $student['address']) { |
|
247 | + Security_user::where('id', $student['student_id']) |
|
248 | 248 | ->update(['address_area_id' => $mother->address_area_id]); |
249 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
250 | - Security_user::where('id',$student['student_id']) |
|
249 | + }elseif (!is_null($guardian) && $guardian->address == $student['address']) { |
|
250 | + Security_user::where('id', $student['student_id']) |
|
251 | 251 | ->update(['address_area_id' => $guardian->address_area_id]); |
252 | 252 | } |
253 | 253 | } |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | $this->academic_period = new Academic_period(); |
32 | 32 | $this->institution_classes = new Institution_class(); |
33 | 33 | $this->institution_class_subjects = new Institution_class_subject(); |
34 | - $this->institution_subjects = new Institution_subject(); |
|
34 | + $this->institution_subjects = new Institution_subject(); |
|
35 | 35 | $this->institution_grades = new Institution_grade(); |
36 | - $this->education_grade_subjects = new Education_grades_subject(); |
|
36 | + $this->education_grade_subjects = new Education_grades_subject(); |
|
37 | 37 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | public function array_walk($shift, $count, $params) |
42 | 42 | { |
43 | - try{ |
|
43 | + try { |
|
44 | 44 | DB::beginTransaction(); |
45 | 45 | array_walk($shift, array($this, 'process'), $params); |
46 | 46 | DB::commit(); |
47 | - }catch(\Exception $e){ |
|
48 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
47 | + }catch (\Exception $e) { |
|
48 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
49 | 49 | DB::rollBack(); |
50 | 50 | } |
51 | 51 | } |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | $this->shifts->where(['cloned' => $academicPeriod->code])->update(['cloned' => $params['previous_academic_period']['code']]); |
60 | 60 | $this->output->writeln('updated shifts'); |
61 | 61 | |
62 | - $classIds = $this->institution_classes->select('id')->where(['academic_period_id' => $academicPeriod->id])->get()->toArray(); |
|
62 | + $classIds = $this->institution_classes->select('id')->where(['academic_period_id' => $academicPeriod->id])->get()->toArray(); |
|
63 | 63 | $this->institution_classes->where(['academic_period_id' => $academicPeriod->id])->delete(); |
64 | 64 | $this->output->writeln('cleaned classes'); |
65 | 65 | |
66 | 66 | do { |
67 | 67 | $deleted = $this->institution_class_subjects->whereRaw("institution_class_id not in (select id from institution_classes where academic_period_id =".$academicPeriod->id." )")->limit(10000)->delete(); |
68 | 68 | $this->output->writeln('cleaned subjects'); |
69 | - }while($deleted > 0); |
|
69 | + } while ($deleted > 0); |
|
70 | 70 | |
71 | 71 | do { |
72 | - $deleted = $this->institution_subjects->where('academic_period_id', $academicPeriod->id)->limit(10000)->delete(); |
|
72 | + $deleted = $this->institution_subjects->where('academic_period_id', $academicPeriod->id)->limit(10000)->delete(); |
|
73 | 73 | $this->output->writeln('10000 institutions cleaned subjects'); |
74 | 74 | } while ($deleted > 0); |
75 | 75 | } |
76 | 76 | |
77 | 77 | public function process($shift, $count, $params) |
78 | 78 | { |
79 | - echo ('[' . getmypid() . ']This Process executed at' . date("F d, Y h:i:s A") . "\n"); |
|
79 | + echo ('['.getmypid().']This Process executed at'.date("F d, Y h:i:s A")."\n"); |
|
80 | 80 | $year = $params['year']; |
81 | 81 | $academicPeriod = $params['academic_period']; |
82 | 82 | $previousAcademicPeriod = $params['previous_academic_period']; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | |
95 | 95 | |
96 | 96 | if ($mode) { |
97 | - $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode, $params); |
|
97 | + $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode, $params); |
|
98 | 98 | try { |
99 | 99 | array_walk($institutionClasses, array($this, 'updateInstitutionClasses'), $params); |
100 | - $this->output->writeln('updating from ' . $shift['institution_id']); |
|
101 | - } catch (\Exception $e) { |
|
100 | + $this->output->writeln('updating from '.$shift['institution_id']); |
|
101 | + }catch (\Exception $e) { |
|
102 | 102 | Log::error($e->getMessage(), [$e]); |
103 | 103 | } |
104 | - } else { |
|
104 | + }else { |
|
105 | 105 | $institutionSubjects = $this->institution_grades->getGradeSubjects($shift['institution_id']); |
106 | 106 | try { |
107 | 107 | if ($data['created']) { |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | try { |
113 | 113 | array_walk($newInstitutionClasses, array($this, 'insertInstitutionClasses'), $params); |
114 | 114 | $this->output->writeln('##########################################################################################################################'); |
115 | - $this->output->writeln('updating from = ' . $shift['institution_id']); |
|
116 | - } catch (\Exception $e) { |
|
117 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
115 | + $this->output->writeln('updating from = '.$shift['institution_id']); |
|
116 | + }catch (\Exception $e) { |
|
117 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
118 | 118 | DB::rollBack(); |
119 | 119 | Log::error($e->getMessage(), [$e]); |
120 | 120 | } |
121 | - } else { |
|
122 | - $this->output->writeln('no classes found ' . $shift['institution_id']); |
|
121 | + }else { |
|
122 | + $this->output->writeln('no classes found '.$shift['institution_id']); |
|
123 | 123 | } |
124 | - } else { |
|
124 | + }else { |
|
125 | 125 | try { |
126 | 126 | $shift['id'] = $shiftId; |
127 | 127 | $institutionClasses = $this->institution_classes->getShiftClasses($shift, $mode); |
128 | 128 | array_walk($institutionClasses, array($this, 'updateInstitutionClasses'), $params); |
129 | 129 | $this->output->writeln('##########################################################################################################################'); |
130 | - $this->output->writeln('updating from ' . $shift['institution_id']); |
|
131 | - } catch (\Exception $e) { |
|
132 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
130 | + $this->output->writeln('updating from '.$shift['institution_id']); |
|
131 | + }catch (\Exception $e) { |
|
132 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
133 | 133 | DB::rollBack(); |
134 | 134 | Log::error($e->getMessage(), [$e]); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | DB::commit(); |
138 | - } catch (\Exception $e) { |
|
138 | + }catch (\Exception $e) { |
|
139 | 139 | Log::error($e->getMessage(), [$e]); |
140 | - $this->output->writeln('Terminating ' . $shift['institution_id']); |
|
140 | + $this->output->writeln('Terminating '.$shift['institution_id']); |
|
141 | 141 | DB::rollBack(); |
142 | 142 | } |
143 | 143 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $subject['created'] = now(); |
157 | 157 | $subject['created_user_id'] = 1; |
158 | 158 | $this->institution_subjects->create($subject); |
159 | - } catch (\Exception $e) { |
|
159 | + }catch (\Exception $e) { |
|
160 | 160 | DB::rollBack(); |
161 | 161 | Log::error($e->getMessage(), [$e]); |
162 | 162 | } |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | try { |
168 | 168 | if ($params['mode']) { |
169 | 169 | Institution_class::where('id', $class['id']) |
170 | - ->where('academic_period_id',$params['previous_academic_period_id']) |
|
170 | + ->where('academic_period_id', $params['previous_academic_period_id']) |
|
171 | 171 | ->update([ |
172 | 172 | 'institution_shift_id' => $params['shift_id'], |
173 | 173 | 'academic_period_id' => $params['academic_period_id'] |
174 | 174 | ]); |
175 | 175 | |
176 | 176 | Institution_class_student::where('institution_class_id', $class['id']) |
177 | - ->where('academic_period_id',$params['previous_academic_period_id']) |
|
177 | + ->where('academic_period_id', $params['previous_academic_period_id']) |
|
178 | 178 | ->update([ |
179 | 179 | 'academic_period_id' => $params['academic_period_id'], |
180 | 180 | 'modified' => now() |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | $educationGrade = Institution_class_grade::select('education_grade_id')->where('institution_class_id', $class['id'])->get()->toArray(); |
184 | 184 | |
185 | 185 | Institution_student::whereIn('education_grade_id', $educationGrade) |
186 | - ->where('academic_period_id',$params['previous_academic_period_id']) |
|
186 | + ->where('academic_period_id', $params['previous_academic_period_id']) |
|
187 | 187 | ->update([ |
188 | 188 | 'academic_period_id' => $params['academic_period_id'] |
189 | 189 | ]); |
190 | 190 | } |
191 | - } catch (\Exception $e) { |
|
191 | + }catch (\Exception $e) { |
|
192 | 192 | DB::rollBack(); |
193 | 193 | Log::error($e->getMessage(), [$e]); |
194 | 194 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | $class['created'] = now(); |
219 | 219 | $class['institution_shift_id'] = $param['shift_id']; |
220 | 220 | // $class['created_user_id'] = |
221 | - $this->output->writeln('Create class:' . $class['name']); |
|
222 | - $class = Institution_class::create($class); |
|
221 | + $this->output->writeln('Create class:'.$class['name']); |
|
222 | + $class = Institution_class::create($class); |
|
223 | 223 | $institutionClassGrdaeObj['institution_class_id'] = $class->id; |
224 | 224 | $institutionClassGrdaeObj['education_grade_id'] = $educationGrdae; |
225 | 225 | $institutionClassGrdaeObj['created_user_id'] = $class['created_user_id']; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | ->toArray(); |
232 | 232 | $params['class'] = $class; |
233 | 233 | $this->insertInstitutionClassSubjects($institutionSubjects, $class); |
234 | - } catch (\Exception $e) { |
|
234 | + }catch (\Exception $e) { |
|
235 | 235 | DB::rollBack(); |
236 | 236 | Log::error($e->getMessage(), [$e]); |
237 | 237 | } |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | if (!empty($subjects)) { |
243 | 243 | try { |
244 | 244 | array_walk($subjects, array($this, 'insertClassSubjects'), $class); |
245 | - $this->output->writeln('updating subjects ' . $class->name); |
|
246 | - } catch (\Exception $e) { |
|
245 | + $this->output->writeln('updating subjects '.$class->name); |
|
246 | + }catch (\Exception $e) { |
|
247 | 247 | DB::rollBack(); |
248 | 248 | Log::error($e->getMessage(), [$e]); |
249 | 249 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | if (!$this->institution_class_subjects->isDuplicated($subjectobj)) { |
265 | 265 | $this->institution_class_subjects->create($subjectobj); |
266 | 266 | } |
267 | - } catch (\Exception $e) { |
|
267 | + }catch (\Exception $e) { |
|
268 | 268 | DB::rollBack(); |
269 | 269 | Log::error($e->getMessage(), [$e]); |
270 | 270 | } |
@@ -312,19 +312,19 @@ discard block |
||
312 | 312 | unset($shift['id']); |
313 | 313 | unset($shift['created']); |
314 | 314 | unset($shift['modified']); |
315 | - $shift = $this->shifts->create((array)$shift); |
|
315 | + $shift = $this->shifts->create((array) $shift); |
|
316 | 316 | $data = [ |
317 | 317 | 'shift_id' => $shift->id, |
318 | 318 | 'created' => true |
319 | 319 | ]; |
320 | - } else { |
|
320 | + }else { |
|
321 | 321 | $data = [ |
322 | 322 | 'shift_id' => $exist->id, |
323 | 323 | 'created' => false |
324 | 324 | ]; |
325 | 325 | }; |
326 | 326 | return $data; |
327 | - } catch (\Exception $e) { |
|
327 | + }catch (\Exception $e) { |
|
328 | 328 | DB::rollBack(); |
329 | 329 | } |
330 | 330 | } |