@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class User_contact extends Base_Model { |
|
7 | +class User_contact extends Base_Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $dates = ['modified', 'created']; |
43 | 43 | |
44 | - public static function createOrUpdate($data,$user){ |
|
44 | + public static function createOrUpdate($data, $user) { |
|
45 | 45 | |
46 | - if(!is_null($data['contact'])){ |
|
46 | + if (!is_null($data['contact'])) { |
|
47 | 47 | $exists = self::where('security_user_id', $data->id) |
48 | - ->where('value',$data['contact']) |
|
48 | + ->where('value', $data['contact']) |
|
49 | 49 | ->first(); |
50 | 50 | |
51 | - if(is_null($exists)){ |
|
51 | + if (is_null($exists)) { |
|
52 | 52 | $data = [ |
53 | 53 | 'security_user_id' => $data->id, |
54 | 54 | 'value' => $data['contact'], |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'preferred' => 1 |
59 | 59 | ]; |
60 | 60 | self::updateOrCreate($data); |
61 | - }else{ |
|
61 | + }else { |
|
62 | 62 | $exists = $exists->toArray(); |
63 | 63 | $exists['preferred'] = 1; |
64 | 64 | $exists['value'] = $data['contact']; |
@@ -58,7 +58,7 @@ |
||
58 | 58 | 'preferred' => 1 |
59 | 59 | ]; |
60 | 60 | self::updateOrCreate($data); |
61 | - }else{ |
|
61 | + } else{ |
|
62 | 62 | $exists = $exists->toArray(); |
63 | 63 | $exists['preferred'] = 1; |
64 | 64 | $exists['value'] = $data['contact']; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Upload extends Model { |
|
7 | +class Upload extends Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | |
44 | 44 | public $timestamps = true; |
45 | 45 | |
46 | - public function user(){ |
|
47 | - return $this->belongsTo('App\Models\Security_user','security_user_id'); |
|
46 | + public function user() { |
|
47 | + return $this->belongsTo('App\Models\Security_user', 'security_user_id'); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function classRoom(){ |
|
51 | - return $this->belongsTo('App\Models\Institution_class','institution_class_id'); |
|
50 | + public function classRoom() { |
|
51 | + return $this->belongsTo('App\Models\Institution_class', 'institution_class_id'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Academic_period extends Base_Model { |
|
7 | +class Academic_period extends Base_Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $dates = ['start_date', 'end_date', 'modified', 'created']; |
43 | 43 | |
44 | - public function getAcademicPeriod($year){ |
|
45 | - return self::query()->where('code',$year)->first(); |
|
44 | + public function getAcademicPeriod($year) { |
|
45 | + return self::query()->where('code', $year)->first(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Identity_type extends Model { |
|
7 | +class Identity_type extends Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -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(empty($gradeOptions) && !is_null($nextProgramme)){ |
|
52 | + if (empty($gradeOptions) && !is_null($nextProgramme)) { |
|
53 | 53 | $programmeId = $nextProgramme->next_programme_id; |
54 | - $gradeOptions = self::where( 'education_programme_id',$programmeId |
|
54 | + $gradeOptions = self::where('education_programme_id', $programmeId |
|
55 | 55 | )->get()->first(); |
56 | 56 | } |
57 | 57 | // Default is to get the list of grades with the next programme grades |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // $results = $gradeOptions; |
67 | 67 | // } |
68 | 68 | return $gradeOptions; |
69 | - } else { |
|
69 | + }else { |
|
70 | 70 | return null; |
71 | 71 | } |
72 | 72 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | |
79 | 79 | foreach ($nextProgrammeList as $nextProgrammeId) { |
80 | 80 | $nextProgrammeGradeResults = self:: |
81 | - where('education_programme_id',$nextProgrammeId->next_programme_id)->get()->toArray(); |
|
81 | + where('education_programme_id', $nextProgrammeId->next_programme_id)->get()->toArray(); |
|
82 | 82 | |
83 | 83 | $results = $results + [key($nextProgrammeGradeResults) => current($nextProgrammeGradeResults)]; |
84 | 84 | } |
85 | - } else { |
|
85 | + }else { |
|
86 | 86 | $results = []; |
87 | 87 | } |
88 | 88 | |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | |
101 | 101 | $nextProgrammeList = $this->getNextProgrammeList($id); |
102 | 102 | if (!empty($nextProgrammeList)) { |
103 | - $results = self::whereIn('education_programme_id',$nextProgrammeList) |
|
103 | + $results = self::whereIn('education_programme_id', $nextProgrammeList) |
|
104 | 104 | ->get()->toArray(); |
105 | - } else { |
|
105 | + }else { |
|
106 | 106 | $results = []; |
107 | 107 | } |
108 | 108 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return array List of next education programmes id |
117 | 117 | */ |
118 | 118 | public function getNextProgrammeList($id) { |
119 | - return Education_programmes_next_programme::where('education_programme_id',$id) |
|
119 | + return Education_programmes_next_programme::where('education_programme_id', $id) |
|
120 | 120 | ->get()->first(); |
121 | 121 | } |
122 | 122 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Illuminate\Database\Eloquent\Model; |
7 | 7 | use Illuminate\Support\Facades\Auth; |
8 | 8 | |
9 | -class Base_Model extends Model{ |
|
9 | +class Base_Model extends Model { |
|
10 | 10 | |
11 | 11 | |
12 | 12 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | parent::boot(); |
21 | - self::creating(function ($model) { |
|
21 | + self::creating(function($model) { |
|
22 | 22 | $model->created = Carbon::now(); |
23 | 23 | }); |
24 | - self::updating(function ($model) { |
|
24 | + self::updating(function($model) { |
|
25 | 25 | $model->modified = Carbon::now(); |
26 | 26 | }); |
27 | 27 | } |
@@ -109,8 +109,9 @@ |
||
109 | 109 | }) |
110 | 110 | ->where('institution_class_id', '=', $student->institution_class_id) |
111 | 111 | ->get()->toArray(); |
112 | - if (!empty($subjectId)) |
|
113 | - $data[] = $subjectId[0]; |
|
112 | + if (!empty($subjectId)) { |
|
113 | + $data[] = $subjectId[0]; |
|
114 | + } |
|
114 | 115 | } |
115 | 116 | return $data; |
116 | 117 | } |
@@ -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,10 +87,10 @@ discard block |
||
87 | 87 | return $mandatorySubject; |
88 | 88 | } |
89 | 89 | |
90 | - public static function getAllSubjects($institutionClass){ |
|
90 | + public static function getAllSubjects($institutionClass) { |
|
91 | 91 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass)->first(); |
92 | 92 | $allSubjects = Institution_class_subject::with(['institutionSubject']) |
93 | - ->whereHas('institutionSubject', function ($query) use ($institutionGrade) { |
|
93 | + ->whereHas('institutionSubject', function($query) use ($institutionGrade) { |
|
94 | 94 | $query->whereHas('institutionGradeSubject')->where('education_grade_id', $institutionGrade->education_grade_id); |
95 | 95 | }) |
96 | 96 | ->where('institution_class_id', '=', $institutionClass) |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | $data = []; |
103 | 103 | foreach ($subjects as $subject) { |
104 | 104 | $subjectId = Institution_class_subject::with(['institutionSubject']) |
105 | - ->whereHas('institutionSubject', function ($query) use ($row, $subject, $student) { |
|
106 | - $query->whereHas('institutionGradeSubject',function($query){ |
|
107 | - $query->where('auto_allocation',0); |
|
105 | + ->whereHas('institutionSubject', function($query) use ($row, $subject, $student) { |
|
106 | + $query->whereHas('institutionGradeSubject', function($query) { |
|
107 | + $query->where('auto_allocation', 0); |
|
108 | 108 | }) |
109 | 109 | ->where('name', '=', $row[$subject]) |
110 | 110 | ->where('education_grade_id', '=', $student->education_grade_id); |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | return $data; |
118 | 118 | } |
119 | 119 | |
120 | - public function getInstitutionClassSubjects($academicPeriodId,$classIds){ |
|
120 | + public function getInstitutionClassSubjects($academicPeriodId, $classIds) { |
|
121 | 121 | return self::query() |
122 | - ->whereIn('institution_class_id',$classIds) |
|
122 | + ->whereIn('institution_class_id', $classIds) |
|
123 | 123 | ->get() |
124 | 124 | ->toArray(); |
125 | 125 | } |
126 | 126 | |
127 | - public function isDuplicated($subject){ |
|
128 | - return self::query()->where('institution_subject_id',$subject['institution_subject_id']) |
|
129 | - ->where('institution_class_id',$subject['institution_class_id'])->get()->toArray(); |
|
127 | + public function isDuplicated($subject) { |
|
128 | + return self::query()->where('institution_subject_id', $subject['institution_subject_id']) |
|
129 | + ->where('institution_class_id', $subject['institution_class_id'])->get()->toArray(); |
|
130 | 130 | } |
131 | 131 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Special_need_difficulty extends Model { |
|
7 | +class Special_need_difficulty extends Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -42,7 +42,7 @@ |
||
42 | 42 | protected $dates = ['modified', 'created']; |
43 | 43 | |
44 | 44 | public function shiftExists($shift){ |
45 | - return self::query() |
|
45 | + return self::query() |
|
46 | 46 | ->where('institution_id',$shift['institution_id']) |
47 | 47 | ->where('location_institution_id',$shift['location_institution_id']) |
48 | 48 | ->where('shift_option_id',$shift['shift_option_id']) |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Institution_shift extends Base_Model { |
|
7 | +class Institution_shift extends Base_Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $dates = ['modified', 'created']; |
43 | 43 | |
44 | - public function shiftExists($shift){ |
|
44 | + public function shiftExists($shift) { |
|
45 | 45 | return self::query() |
46 | - ->where('institution_id',$shift['institution_id']) |
|
47 | - ->where('location_institution_id',$shift['location_institution_id']) |
|
48 | - ->where('shift_option_id',$shift['shift_option_id']) |
|
49 | - ->where('academic_period_id',$shift['academic_period_id'])->exists(); |
|
46 | + ->where('institution_id', $shift['institution_id']) |
|
47 | + ->where('location_institution_id', $shift['location_institution_id']) |
|
48 | + ->where('shift_option_id', $shift['shift_option_id']) |
|
49 | + ->where('academic_period_id', $shift['academic_period_id'])->exists(); |
|
50 | 50 | } |
51 | 51 | |
52 | - public function getShiftsToClone(int $year){ |
|
52 | + public function getShiftsToClone(int $year) { |
|
53 | 53 | return self::query() |
54 | 54 | ->select('institution_shifts.*') |
55 | - ->join('academic_periods','academic_periods.id','=','institution_shifts.academic_period_id') |
|
55 | + ->join('academic_periods', 'academic_periods.id', '=', 'institution_shifts.academic_period_id') |
|
56 | 56 | // ->where('academic_periods.code',$year) |
57 | - ->where('institution_shifts.cloned',$year) |
|
57 | + ->where('institution_shifts.cloned', $year) |
|
58 | 58 | ->get()->toArray(); |
59 | 59 | } |
60 | 60 | |
61 | - public function getShiftsTodelete(int $year,$academic_period_id){ |
|
61 | + public function getShiftsTodelete(int $year, $academic_period_id) { |
|
62 | 62 | return self::query() |
63 | 63 | ->select('institution_shifts.*') |
64 | - ->join('academic_periods','academic_periods.id','=','institution_shifts.academic_period_id') |
|
65 | - ->where('academic_period_id',$academic_period_id) |
|
66 | - ->where('institution_shifts.cloned',$year) |
|
64 | + ->join('academic_periods', 'academic_periods.id', '=', 'institution_shifts.academic_period_id') |
|
65 | + ->where('academic_period_id', $academic_period_id) |
|
66 | + ->where('institution_shifts.cloned', $year) |
|
67 | 67 | ->get()->toArray(); |
68 | 68 | } |
69 | 69 | } |