@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - public function getShiftClasses($shift, $al , $param = []) |
|
| 63 | + public function getShiftClasses($shift, $al, $param = []) |
|
| 64 | 64 | { |
| 65 | 65 | $query = self::query() |
| 66 | 66 | ->select( |
@@ -75,20 +75,20 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | ) |
| 77 | 77 | ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id') |
| 78 | - ->join('education_grades','institution_class_grades.education_grade_id','education_grades.id') |
|
| 78 | + ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
|
| 79 | 79 | ->join('education_programmes', 'education_grades.education_programme_id', 'education_programmes.id') |
| 80 | - ->join('education_cycles', 'education_programmes.education_cycle_id','education_cycles.id') |
|
| 80 | + ->join('education_cycles', 'education_programmes.education_cycle_id', 'education_cycles.id') |
|
| 81 | 81 | ->groupBy('institution_classes.id'); |
| 82 | 82 | |
| 83 | 83 | if ($al == true) { |
| 84 | 84 | $query->where('education_programmes.education_cycle_id', 4) |
| 85 | 85 | ->where('institution_shift_id', $shift['id']) |
| 86 | - ->where('institution_classes.academic_period_id',$param['previous_academic_period_id']); |
|
| 86 | + ->where('institution_classes.academic_period_id', $param['previous_academic_period_id']); |
|
| 87 | 87 | $data = $query |
| 88 | 88 | ->groupBy('institution_classes.id') |
| 89 | 89 | ->get()->toArray(); |
| 90 | 90 | return $data; |
| 91 | - } else { |
|
| 91 | + }else { |
|
| 92 | 92 | $query |
| 93 | 93 | // ->where('education_programmes.education_cycle_id','<>',4) |
| 94 | 94 | ->where('institution_shift_id', $shift['id']); |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function getGradeClasses($education_grade_id,$institution_id){ |
|
| 102 | + public static function getGradeClasses($education_grade_id, $institution_id) { |
|
| 103 | 103 | return self::query() |
| 104 | - ->select('institution_classes.id','institution_classes.institution_id','institution_classes.institution_shift_id', |
|
| 105 | - 'institution_classes.name','institution_classes.no_of_students','institution_classes.class_number','institution_class_grades.education_grade_id') |
|
| 106 | - ->where('institution_class_grades.education_grade_id',$education_grade_id) |
|
| 107 | - ->where('institution_classes.institution_id',$institution_id) |
|
| 108 | - ->join('institution_class_grades','institution_classes.id','institution_class_grades.institution_class_id') |
|
| 104 | + ->select('institution_classes.id', 'institution_classes.institution_id', 'institution_classes.institution_shift_id', |
|
| 105 | + 'institution_classes.name', 'institution_classes.no_of_students', 'institution_classes.class_number', 'institution_class_grades.education_grade_id') |
|
| 106 | + ->where('institution_class_grades.education_grade_id', $education_grade_id) |
|
| 107 | + ->where('institution_classes.institution_id', $institution_id) |
|
| 108 | + ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id') |
|
| 109 | 109 | ->get()->toArray(); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | if (!empty($isAvailableforPromotion)) { |
| 65 | 65 | $this->process($institutionGrade, $nextGrade, $params); |
| 66 | 66 | DB::commit(); |
| 67 | - } else { |
|
| 67 | + }else { |
|
| 68 | 68 | DB::rollBack(); |
| 69 | 69 | } |
| 70 | 70 | //leave school levers |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // $this->process($institutionGrade, $nextGrade, $params); |
| 73 | 73 | // } |
| 74 | 74 | } |
| 75 | - } catch (\Exception $e) { |
|
| 75 | + }catch (\Exception $e) { |
|
| 76 | 76 | DB::rollBack(); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 107 | 107 | $output->writeln('##########################################################################################################################'); |
| 108 | - $output->writeln('Promoting from ' . $institutionGrade['name'] . ' IN ' . $institution->name . ' No of Students: ' . count($studentListToPromote)); |
|
| 108 | + $output->writeln('Promoting from '.$institutionGrade['name'].' IN '.$institution->name.' No of Students: '.count($studentListToPromote)); |
|
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | if (!empty($parallelClasses)) { |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | array_walk($parallelClasses, array($this, 'updateStudentCount')); |
| 121 | 121 | DB::commit(); |
| 122 | 122 | } |
| 123 | - } catch (\Exception $e) { |
|
| 123 | + }catch (\Exception $e) { |
|
| 124 | 124 | DB::rollBack(); |
| 125 | 125 | Log::error($e->getMessage()); |
| 126 | 126 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $previousAcademicPeriod = $params['previousAcademicPeriod']; |
| 156 | 156 | $nextGradeObj = null; |
| 157 | 157 | $currentGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $institutionGrade['education_grade_id'], $previousAcademicPeriod->id); |
| 158 | - if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
| 158 | + if ($nextGrade !== [] && !is_null($nextGrade)) { |
|
| 159 | 159 | $nextGradeObj = $this->instituion_grade->getParallelClasses($institutionGrade['id'], $institutionGrade['institution_id'], $nextGrade->id, $academicPeriod->id); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | // promote parallel classes |
| 165 | 165 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, $nextGradeObj->toArray(), 1); |
| 166 | 166 | return 1; |
| 167 | - } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
| 167 | + } elseif (($nextGradeObj->count() > 1) && ($nextGradeObj->count() !== $currentGradeObj->count())) { |
|
| 168 | 168 | // promote pool promotion |
| 169 | 169 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, [], 1); |
| 170 | 170 | return 2; |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | // Promote matching class name with previous class |
| 173 | 173 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, $nextGradeObj->toArray(), 1); |
| 174 | 174 | return 1; |
| 175 | - } else { |
|
| 175 | + }else { |
|
| 176 | 176 | // default pool promotion |
| 177 | 177 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, [], 1); |
| 178 | 178 | return 2; |
| 179 | 179 | } |
| 180 | - } else { |
|
| 180 | + }else { |
|
| 181 | 181 | // default pool promotion |
| 182 | 182 | $this->promotion($institutionGrade, $nextGrade, $previousAcademicPeriod, $academicPeriod, [], 3); |
| 183 | 183 | return 2; |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | ]; |
| 214 | 214 | |
| 215 | 215 | try { |
| 216 | - Institution_student::where('id', (string)$student['id'])->update($studentData); |
|
| 216 | + Institution_student::where('id', (string) $student['id'])->update($studentData); |
|
| 217 | 217 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 218 | - $output->writeln('----------------- ' . $student['admission_id'] . ' to ' . $studentData['education_grade_id']); |
|
| 219 | - } catch (\Exception $e) { |
|
| 218 | + $output->writeln('----------------- '.$student['admission_id'].' to '.$studentData['education_grade_id']); |
|
| 219 | + }catch (\Exception $e) { |
|
| 220 | 220 | Log::error($e->getMessage()); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -236,13 +236,13 @@ discard block |
||
| 236 | 236 | $studentClass = $this->institution_class_students->getStudentNewClass($student); |
| 237 | 237 | if (!is_null($studentClass)) { |
| 238 | 238 | $class = array_search(str_replace($educationGrade['name'], $nextGrade->name, $studentClass->name), array_column($classes, 'name')); |
| 239 | - if(!($class)){ |
|
| 240 | - $nextGradeName = explode(" ",$nextGrade->name)[0]; |
|
| 241 | - $educationGrade['name'] = explode(" ",$educationGrade['name'])[0]; |
|
| 239 | + if (!($class)) { |
|
| 240 | + $nextGradeName = explode(" ", $nextGrade->name)[0]; |
|
| 241 | + $educationGrade['name'] = explode(" ", $educationGrade['name'])[0]; |
|
| 242 | 242 | $class = array_search(str_replace($educationGrade['name'], $nextGradeName, $studentClass->name), array_column($classes, 'name')); |
| 243 | 243 | } |
| 244 | 244 | return $class; |
| 245 | - } else { |
|
| 245 | + }else { |
|
| 246 | 246 | return false; |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $class = null; |
| 265 | 265 | if (count($classes) == 1) { |
| 266 | 266 | $class = $classes[0]; |
| 267 | - } else { |
|
| 267 | + }else { |
|
| 268 | 268 | $class = $this->getStudentClass($student, $educationGrade, $nextGrade, $classes); |
| 269 | 269 | if (is_numeric($class)) { |
| 270 | 270 | $class = $classes[$class]; |
@@ -296,13 +296,13 @@ discard block |
||
| 296 | 296 | // array_walk($allInsSubjects,array($this,'updateSubjectCount')); |
| 297 | 297 | // } |
| 298 | 298 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 299 | - $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']); |
|
| 300 | - } else { |
|
| 301 | - $this->institution_class_students->where('id', (string)$student['id'])->update($studentObj); |
|
| 299 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
| 300 | + }else { |
|
| 301 | + $this->institution_class_students->where('id', (string) $student['id'])->update($studentObj); |
|
| 302 | 302 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 303 | - $output->writeln('----------------- ' . $student['student_id'] . 'to ' . $class['name']); |
|
| 303 | + $output->writeln('----------------- '.$student['student_id'].'to '.$class['name']); |
|
| 304 | 304 | } |
| 305 | - } catch (\Exception $e) { |
|
| 305 | + }catch (\Exception $e) { |
|
| 306 | 306 | |
| 307 | 307 | Log::error($e->getMessage()); |
| 308 | 308 | } |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | public function getParallelClasses($id, $institutionId, $educationGradeId, $academicPeriodId) |
| 71 | 71 | { |
| 72 | 72 | $data = self::find($id)->select('institution_grades.id as insGrade', 'institution_classes.id', 'institution_classes.name', 'institution_grades.education_grade_id') |
| 73 | - ->join('institution_classes', function ($join) use ($educationGradeId, $academicPeriodId) { |
|
| 73 | + ->join('institution_classes', function($join) use ($educationGradeId, $academicPeriodId) { |
|
| 74 | 74 | $join->on('institution_classes.institution_id', '=', 'institution_grades.institution_id') |
| 75 | 75 | ->where('institution_classes.academic_period_id', $academicPeriodId) |
| 76 | - ->join('institution_class_grades', function ($join) use ($educationGradeId) { |
|
| 76 | + ->join('institution_class_grades', function($join) use ($educationGradeId) { |
|
| 77 | 77 | $join->on('institution_class_grades.institution_class_id', '=', 'institution_classes.id') |
| 78 | 78 | ->where('institution_class_grades.education_grade_id', $educationGradeId); |
| 79 | 79 | }) |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | ->select('education_grades.name', 'institutions.code', 'institutions.name as institution_name', 'institution_grades.id', 'institution_grades.institution_id', 'institution_grades.education_grade_id') |
| 124 | 124 | // ->where('promoted', '=', $year) |
| 125 | 125 | ->join('education_grades', 'institution_grades.education_grade_id', '=', 'education_grades.id') |
| 126 | - ->join('institutions', function ($join) use ($year, $institution) { |
|
| 126 | + ->join('institutions', function($join) use ($year, $institution) { |
|
| 127 | 127 | $join->on('institutions.id', '=', 'institution_grades.institution_id') |
| 128 | 128 | ->where('institutions.code', '=', $institution); |
| 129 | 129 | }) |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | break; |
| 135 | 135 | case '6-11': |
| 136 | 136 | $query->whereIn('education_programmes.education_cycle_id', [2, 3]); |
| 137 | - $query->whereNotIn('education_grades.id',[29,34]); |
|
| 137 | + $query->whereNotIn('education_grades.id', [29, 34]); |
|
| 138 | 138 | break; |
| 139 | 139 | case 'AL': |
| 140 | 140 | $query->where('education_programmes.education_cycle_id', 4); |
@@ -152,21 +152,21 @@ discard block |
||
| 152 | 152 | * @param $year |
| 153 | 153 | * @return mixed |
| 154 | 154 | */ |
| 155 | - public function getInstitutionGradeList($year, $limit,$mode) |
|
| 155 | + public function getInstitutionGradeList($year, $limit, $mode) |
|
| 156 | 156 | { |
| 157 | 157 | $query = $this->select('education_grades.name', 'institutions.code', 'institutions.name as institution_name', 'institution_grades.id', 'institution_grades.institution_id', 'institution_grades.education_grade_id') |
| 158 | 158 | // ->where('promoted', '=', $year) |
| 159 | 159 | ->join('education_grades', 'institution_grades.education_grade_id', '=', 'education_grades.id') |
| 160 | - ->join('institutions', function ($join) use ($year) { |
|
| 160 | + ->join('institutions', function($join) use ($year) { |
|
| 161 | 161 | $join->on('institutions.id', '=', 'institution_grades.institution_id'); |
| 162 | 162 | }) |
| 163 | 163 | ->join('education_programmes', 'education_grades.education_programme_id', 'education_programmes.id'); |
| 164 | 164 | switch ($mode) { |
| 165 | 165 | case '1-5': |
| 166 | - $query->whereIn('education_programmes.education_cycle_id', [1,2]); |
|
| 166 | + $query->whereIn('education_programmes.education_cycle_id', [1, 2]); |
|
| 167 | 167 | break; |
| 168 | 168 | case '6-11': |
| 169 | - $query->whereIn('education_programmes.education_cycle_id', [2,3,4]); |
|
| 169 | + $query->whereIn('education_programmes.education_cycle_id', [2, 3, 4]); |
|
| 170 | 170 | break; |
| 171 | 171 | case 'AL': |
| 172 | 172 | $query->where('education_programmes.education_cycle_id', 4); |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | return $data; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function getGradeSubjects($institutionId){ |
|
| 184 | + public function getGradeSubjects($institutionId) { |
|
| 185 | 185 | return self::query() |
| 186 | - ->select('institution_grades.institution_id','education_grades_subjects.education_grade_id','education_grades_subjects.education_subject_id','education_subjects.name') |
|
| 187 | - ->where('institution_grades.institution_id',$institutionId) |
|
| 186 | + ->select('institution_grades.institution_id', 'education_grades_subjects.education_grade_id', 'education_grades_subjects.education_subject_id', 'education_subjects.name') |
|
| 187 | + ->where('institution_grades.institution_id', $institutionId) |
|
| 188 | 188 | ->join('education_grades', 'institution_grades.education_grade_id', 'education_grades.id') |
| 189 | - ->join('education_grades_subjects','education_grades.id','education_grades_subjects.education_grade_id') |
|
| 190 | - ->join('education_subjects','education_grades_subjects.education_subject_id','education_subjects.id') |
|
| 189 | + ->join('education_grades_subjects', 'education_grades.id', 'education_grades_subjects.education_grade_id') |
|
| 190 | + ->join('education_subjects', 'education_grades_subjects.education_subject_id', 'education_subjects.id') |
|
| 191 | 191 | ->groupBy('education_grades_subjects.id') |
| 192 | 192 | ->get() |
| 193 | 193 | ->toArray(); |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function boot() |
| 29 | 29 | { |
| 30 | 30 | // |
| 31 | - if(!(\App::environment('local'))) { |
|
| 31 | + if (!(\App::environment('local'))) { |
|
| 32 | 32 | URL::forceScheme('https'); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class Security_group_institution extends Model { |
|
| 7 | +class Security_group_institution extends Model { |
|
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -44,21 +44,21 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | - public function institution(){ |
|
| 48 | - return $this->belongsTo('App\Models\Institution','institution_id'); |
|
| 47 | + public function institution() { |
|
| 48 | + return $this->belongsTo('App\Models\Institution', 'institution_id'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function institution_classes(){ |
|
| 52 | - return $this->hasMany('App\Models\Institution_class','institution_id','institution_id') |
|
| 51 | + public function institution_classes() { |
|
| 52 | + return $this->hasMany('App\Models\Institution_class', 'institution_id', 'institution_id') |
|
| 53 | 53 | ->select('institution_classes.*') |
| 54 | - ->join('academic_periods', function($query){ |
|
| 55 | - $query->on('institution_classes.academic_period_id','academic_periods.id'); |
|
| 56 | - $query->whereIn('academic_periods.code',['2020','2019/2020']); |
|
| 54 | + ->join('academic_periods', function($query) { |
|
| 55 | + $query->on('institution_classes.academic_period_id', 'academic_periods.id'); |
|
| 56 | + $query->whereIn('academic_periods.code', ['2020', '2019/2020']); |
|
| 57 | 57 | }); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function security_group(){ |
|
| 61 | - return $this->belongsTo('App\Models\Security_group','security_group_id'); |
|
| 60 | + public function security_group() { |
|
| 61 | + return $this->belongsTo('App\Models\Security_group', 'security_group_id'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class Security_group_user extends Model { |
|
| 7 | +class Security_group_user extends Model { |
|
| 8 | 8 | |
| 9 | 9 | public const CREATED_AT = 'created'; |
| 10 | 10 | public const UPDATED_AT = 'modified'; |
@@ -45,39 +45,39 @@ discard block |
||
| 45 | 45 | protected $dates = ['modified', 'created', 'created']; |
| 46 | 46 | |
| 47 | 47 | |
| 48 | - public function security_user(){ |
|
| 49 | - return $this->belongsToMany('App\Models\User','security_users'); |
|
| 48 | + public function security_user() { |
|
| 49 | + return $this->belongsToMany('App\Models\User', 'security_users'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function security_group(){ |
|
| 53 | - return $this->hasMany('App\Models\Security_group' , 'id','security_group_id'); |
|
| 52 | + public function security_group() { |
|
| 53 | + return $this->hasMany('App\Models\Security_group', 'id', 'security_group_id'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function security_group_institution(){ |
|
| 57 | - return $this->belongsTo('App\Models\Security_group_institution','security_group_id','security_group_id'); |
|
| 56 | + public function security_group_institution() { |
|
| 57 | + return $this->belongsTo('App\Models\Security_group_institution', 'security_group_id', 'security_group_id'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function staff_class(){ |
|
| 61 | - return $this->hasMany('App\Models\Institution_class','staff_id','security_user_id') |
|
| 60 | + public function staff_class() { |
|
| 61 | + return $this->hasMany('App\Models\Institution_class', 'staff_id', 'security_user_id') |
|
| 62 | 62 | ->select('institution_classes.*') |
| 63 | - ->join('academic_periods',function($query){ |
|
| 64 | - $query->on('institution_classes.academic_period_id','academic_periods.id'); |
|
| 65 | - $query->whereIn('academic_periods.code',['2020','2019/2020']); |
|
| 63 | + ->join('academic_periods', function($query) { |
|
| 64 | + $query->on('institution_classes.academic_period_id', 'academic_periods.id'); |
|
| 65 | + $query->whereIn('academic_periods.code', ['2020', '2019/2020']); |
|
| 66 | 66 | }); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function institution_staff(){ |
|
| 70 | - return $this->belongsTo('App\Models\Institution_staff','security_user_id','staff_id'); |
|
| 69 | + public function institution_staff() { |
|
| 70 | + return $this->belongsTo('App\Models\Institution_staff', 'security_user_id', 'staff_id'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function institution_group(){ |
|
| 74 | - return $this->hasMany('App\Models\Security_group_institution','security_group_id','security_group_id') |
|
| 75 | - ->with(['institution','institution_classes']); |
|
| 73 | + public function institution_group() { |
|
| 74 | + return $this->hasMany('App\Models\Security_group_institution', 'security_group_id', 'security_group_id') |
|
| 75 | + ->with(['institution', 'institution_classes']); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | - public function roles(){ |
|
| 80 | - return $this->belongsTo('App\Models\Security_role','security_role_id','id'); |
|
| 79 | + public function roles() { |
|
| 80 | + return $this->belongsTo('App\Models\Security_role', 'security_role_id', 'id'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class Institution_staff extends Model { |
|
| 7 | +class Institution_staff extends Model { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * The database table used by the model. |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | protected $dates = ['start_date', 'end_date', 'modified', 'created']; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - public function staff_class(){ |
|
| 46 | - return $this->hasMany('App\Models\Institution_class','staff_id','staff_id') |
|
| 47 | - ->innerJoin('academic_periods','institution_classes.academic_period_id','academic_periods.id') |
|
| 48 | - ->where('academic_periods.current',1); |
|
| 45 | + public function staff_class() { |
|
| 46 | + return $this->hasMany('App\Models\Institution_class', 'staff_id', 'staff_id') |
|
| 47 | + ->innerJoin('academic_periods', 'institution_classes.academic_period_id', 'academic_periods.id') |
|
| 48 | + ->where('academic_periods.current', 1); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function institution(){ |
|
| 52 | - return $this->belongsTo('App\Models\Institution','institution_id'); |
|
| 51 | + public function institution() { |
|
| 52 | + return $this->belongsTo('App\Models\Institution', 'institution_id'); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param Request $request |
| 34 | 34 | * @return \Illuminate\Http\JsonResponse |
| 35 | 35 | */ |
| 36 | - public function upload(Request $request){ |
|
| 36 | + public function upload(Request $request) { |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $institution = auth()->user()->permissions->isEmpty() ? auth()->user()->principal[0]->institution_group[0]->institution->code : auth()->user()->permissions[0]->institution_staff->institution->code; |
| 76 | 76 | |
| 77 | 77 | |
| 78 | - $fileName = time().'_'.$institution.'_'.str_replace(' ','_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
| 78 | + $fileName = time().'_'.$institution.'_'.str_replace(' ', '_', clean($class->name)).'_'.auth()->user()->openemis_no.'_student_bulk_data.xlsx'; |
|
| 79 | 79 | Storage::disk('local')->putFileAs( |
| 80 | 80 | 'sis-bulk-data-files/', |
| 81 | 81 | $uploadFile, |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | 85 | $upload = new Upload; |
| 86 | - $upload->fileName =$fileName; |
|
| 86 | + $upload->fileName = $fileName; |
|
| 87 | 87 | $upload->model = 'Student'; |
| 88 | 88 | $upload->node = 'None'; |
| 89 | 89 | $upload->institution_class_id = $class->id; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | return redirect('/')->withSuccess('The file is uploaded, we will process and let you know by your email'); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function updateQueueWithUnprocessedFiles($id, $action){ |
|
| 98 | - if($action == 100){ |
|
| 97 | + public function updateQueueWithUnprocessedFiles($id, $action) { |
|
| 98 | + if ($action == 100) { |
|
| 99 | 99 | DB::table('uploads') |
| 100 | 100 | ->where('id', $id) |
| 101 | 101 | ->update(['is_processed' => 0]); |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - public function downloadTemplate(){ |
|
| 110 | + public function downloadTemplate() { |
|
| 111 | 111 | $filename = 'censusNo_className_sis_students_bulk_upload'; |
| 112 | 112 | $version = '2007_V2.0.2_20201211.xlsx'; |
| 113 | - $file_path = storage_path() .'/app/public/'. $filename.'_'.$version;; |
|
| 113 | + $file_path = storage_path().'/app/public/'.$filename.'_'.$version; ; |
|
| 114 | 114 | if (file_exists($file_path)) |
| 115 | 115 | { |
| 116 | 116 | return Response::download($file_path, Auth::user()->openemis_no.'_'.$filename.$version, [ |
| 117 | - 'Content-Length: '. filesize($file_path) |
|
| 117 | + 'Content-Length: '.filesize($file_path) |
|
| 118 | 118 | ]); |
| 119 | 119 | } |
| 120 | 120 | else |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | * @param $filename |
| 129 | 129 | * @return Processed excel file with error |
| 130 | 130 | */ |
| 131 | - public function downloadErrorFile($filename){ |
|
| 131 | + public function downloadErrorFile($filename) { |
|
| 132 | 132 | |
| 133 | - $file_path = storage_path().'/app/sis-bulk-data-files/processed/'. $filename; |
|
| 133 | + $file_path = storage_path().'/app/sis-bulk-data-files/processed/'.$filename; |
|
| 134 | 134 | if (file_exists($file_path)) |
| 135 | 135 | { |
| 136 | 136 | return Response::download($file_path, $filename, [ |
| 137 | - 'Content-Length: '. filesize($file_path) |
|
| 137 | + 'Content-Length: '.filesize($file_path) |
|
| 138 | 138 | ]); |
| 139 | 139 | } |
| 140 | 140 | else |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
| 147 | - public function downloadFile($filename){ |
|
| 148 | - $file_path = storage_path().'/app/sis-bulk-data-files/'. $filename; |
|
| 147 | + public function downloadFile($filename) { |
|
| 148 | + $file_path = storage_path().'/app/sis-bulk-data-files/'.$filename; |
|
| 149 | 149 | if (file_exists($file_path)) |
| 150 | 150 | { |
| 151 | 151 | return Response::download($file_path, $filename, [ |
| 152 | - 'Content-Length: '. filesize($file_path) |
|
| 152 | + 'Content-Length: '.filesize($file_path) |
|
| 153 | 153 | ]); |
| 154 | 154 | } |
| 155 | 155 | else |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $studentData['id'] = $id; |
| 205 | 205 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
| 206 | 206 | return $studentData; |
| 207 | - } catch (\Exception $th) { |
|
| 207 | + }catch (\Exception $th) { |
|
| 208 | 208 | Log::error($th->getMessage()); |
| 209 | 209 | // in case of duplication of the Unique ID this will recursive. |
| 210 | 210 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $this->uniqueUserId = new Unique_user_id(); |
| 226 | 226 | $this->uniqueUId = new UniqueUid(); |
| 227 | 227 | // regenerate unique id if it's not available |
| 228 | - $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
| 228 | + $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
| 229 | 229 | |
| 230 | 230 | $studentData = [ |
| 231 | 231 | 'username' => str_replace('-', '', $uniqueId), |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $studentData['id'] = $sis_student['student_id']; |
| 244 | 244 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
| 245 | 245 | return $studentData; |
| 246 | - } catch (\Exception $th) { |
|
| 246 | + }catch (\Exception $th) { |
|
| 247 | 247 | Log::error($th); |
| 248 | 248 | // in case of duplication of the Unique ID this will recursive. |
| 249 | 249 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | try { |
| 257 | 257 | $uniqueUid = new UniqueUid(); |
| 258 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
| 259 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
| 260 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
| 258 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
| 259 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
| 260 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
| 261 | 261 | |
| 262 | 262 | $date = $row['date_of_birth_yyyy_mm_dd']; |
| 263 | 263 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | ]); |
| 290 | 290 | case 'update': |
| 291 | 291 | if (!is_null($row['student_id'])) { |
| 292 | - $studentInfo = Security_user::where('openemis_no',trim($row['student_id']))->first(); |
|
| 292 | + $studentInfo = Security_user::where('openemis_no', trim($row['student_id']))->first(); |
|
| 293 | 293 | self::query()->where('openemis_no', $row['student_id']) |
| 294 | 294 | ->update([ |
| 295 | 295 | 'first_name' => $row['full_name'] ? $row['full_name'] : $studentInfo['first_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | - } catch (\Exception $e) { |
|
| 313 | + }catch (\Exception $e) { |
|
| 314 | 314 | dd($e); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -319,48 +319,48 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | try { |
| 321 | 321 | $uniqueUid = new UniqueUid(); |
| 322 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row[$prefix . 's_address_area'] . '%')->first(); |
|
| 323 | - $nationalityId = Nationality::where('name', 'like', '%' . $row[$prefix . 's_nationality'] . '%')->first(); |
|
| 324 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row[$prefix . 's_identity_type'] . '%')->first(); |
|
| 322 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row[$prefix.'s_address_area'].'%')->first(); |
|
| 323 | + $nationalityId = Nationality::where('name', 'like', '%'.$row[$prefix.'s_nationality'].'%')->first(); |
|
| 324 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row[$prefix.'s_identity_type'].'%')->first(); |
|
| 325 | 325 | $openemisNo = $uniqueUid::getUniqueAlphanumeric(); |
| 326 | 326 | |
| 327 | 327 | $identityType = ($identityType !== null) ? $identityType->id : null; |
| 328 | 328 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
| 329 | 329 | |
| 330 | 330 | $guardian = null; |
| 331 | - if (!empty($row[$prefix . 's_identity_number'])) { |
|
| 331 | + if (!empty($row[$prefix.'s_identity_number'])) { |
|
| 332 | 332 | $guardian = Security_user::where('identity_type_id', '=', $nationalityId) |
| 333 | - ->where('identity_number', '=', $row[$prefix . 's_identity_number'])->first(); |
|
| 333 | + ->where('identity_number', '=', $row[$prefix.'s_identity_number'])->first(); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | if (is_null($guardian)) { |
| 337 | 337 | $guardian = self::create([ |
| 338 | 338 | 'username' => str_replace('-', '', $openemisNo), |
| 339 | 339 | 'openemis_no' => $openemisNo, |
| 340 | - 'first_name' => $row[$prefix . 's_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
|
| 341 | - 'last_name' => genNameWithInitials($row[$prefix . 's_full_name']), |
|
| 340 | + 'first_name' => $row[$prefix.'s_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
|
| 341 | + 'last_name' => genNameWithInitials($row[$prefix.'s_full_name']), |
|
| 342 | 342 | 'gender_id' => 1, |
| 343 | - 'date_of_birth' => $row[$prefix . 's_date_of_birth_yyyy_mm_dd'], |
|
| 344 | - 'address' => $row[$prefix . 's_address'], |
|
| 343 | + 'date_of_birth' => $row[$prefix.'s_date_of_birth_yyyy_mm_dd'], |
|
| 344 | + 'address' => $row[$prefix.'s_address'], |
|
| 345 | 345 | 'address_area_id' => $AddressArea ? $AddressArea->id : null, |
| 346 | 346 | 'nationality_id' => $nationalityId, |
| 347 | 347 | 'identity_type_id' => $identityType, |
| 348 | - 'identity_number' => $row[$prefix . 's_identity_number'], |
|
| 348 | + 'identity_number' => $row[$prefix.'s_identity_number'], |
|
| 349 | 349 | 'is_guardian' => 1, |
| 350 | 350 | 'created_user_id' => $file['security_user_id'] |
| 351 | 351 | ]); |
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | $guardian['guardian_relation_id'] = 1; |
| 355 | - if (array_key_exists($prefix . 's_phone', $row)) { |
|
| 356 | - $father['contact'] = $row[$prefix . 's_phone']; |
|
| 355 | + if (array_key_exists($prefix.'s_phone', $row)) { |
|
| 356 | + $father['contact'] = $row[$prefix.'s_phone']; |
|
| 357 | 357 | User_contact::createOrUpdate($father, $file['security_user_id']); |
| 358 | 358 | } |
| 359 | - } else { |
|
| 360 | - Security_user::where('id', $guardian->id)->update(['address_area_id' => $AddressArea ? $AddressArea->id : null,]); |
|
| 359 | + }else { |
|
| 360 | + Security_user::where('id', $guardian->id)->update(['address_area_id' => $AddressArea ? $AddressArea->id : null, ]); |
|
| 361 | 361 | } |
| 362 | 362 | return $guardian; |
| 363 | - } catch (\Exception $e) { |
|
| 363 | + }catch (\Exception $e) { |
|
| 364 | 364 | Log::error($e->getMessage(), [$e]); |
| 365 | 365 | } |
| 366 | 366 | } |