@@ -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 |
@@ -72,18 +72,18 @@ |
||
72 | 72 | 'institution_id' => $admissionInfo['instituion']->id, |
73 | 73 | 'academic_period_id' => $admissionInfo['academic_period']->id, |
74 | 74 | 'education_grade_id' => $admissionInfo['education_grade']->id, |
75 | - 'institution_class_id' => (($admissionInfo['instituion_class'] != []) && (count($admissionInfo['instituion_class'])==1)) ? $admissionInfo['instituion_class']['id'] : null, |
|
75 | + 'institution_class_id' => (($admissionInfo['instituion_class'] != []) && (count($admissionInfo['instituion_class']) == 1)) ? $admissionInfo['instituion_class']['id'] : null, |
|
76 | 76 | 'comment' => 'Imported From Examination Data', |
77 | 77 | 'updated_from' => 'doe', |
78 | 78 | 'created_user_id' => 1 |
79 | 79 | ]; |
80 | 80 | self::create($data); |
81 | - } catch (\Throwable $th) { |
|
81 | + }catch (\Throwable $th) { |
|
82 | 82 | Log::error($th); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - public static function createAdmission($studentId,$row,$params,$file){ |
|
86 | + public static function createAdmission($studentId, $row, $params, $file) { |
|
87 | 87 | self::create([ |
88 | 88 | 'start_date' => $row['start_date_yyyy_mm_dd'], |
89 | 89 | 'start_year' => $row['start_date_yyyy_mm_dd']->format('Y'), |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class Security_group extends Model { |
|
7 | +class Security_group extends Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $dates = ['modified', 'created', 'created', 'created', 'modified', 'created']; |
43 | 43 | |
44 | - public function security_users(){ |
|
45 | - return $this->belongsTo('App\Models\Security_group_user','security_group_id'); |
|
44 | + public function security_users() { |
|
45 | + return $this->belongsTo('App\Models\Security_group_user', 'security_group_id'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | - public function security_group_institution(){ |
|
50 | - return $this->hasMany('App\Models\Security_group_institution','security_group_id'); |
|
49 | + public function security_group_institution() { |
|
50 | + return $this->hasMany('App\Models\Security_group_institution', 'security_group_id'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
54 | 54 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Illuminate\Database\Eloquent\SoftDeletes; |
8 | 8 | use Webpatser\Uuid\Uuid; |
9 | 9 | |
10 | -class Student_guardian extends Base_Model { |
|
10 | +class Student_guardian extends Base_Model { |
|
11 | 11 | |
12 | 12 | use SoftDeletes; |
13 | 13 | |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | public static function boot() |
60 | 60 | { |
61 | 61 | parent::boot(); |
62 | - self::creating(function ($model) { |
|
62 | + self::creating(function($model) { |
|
63 | 63 | $model->id = (string) Uuid::generate(4); |
64 | 64 | $model->created_user_id = 1; |
65 | 65 | }); |
66 | 66 | } |
67 | 67 | |
68 | - public static function createStudentGuardian($student,$guardian,$user){ |
|
68 | + public static function createStudentGuardian($student, $guardian, $user) { |
|
69 | 69 | |
70 | 70 | $exist = true; |
71 | - if(!is_null($guardian)) |
|
71 | + if (!is_null($guardian)) |
|
72 | 72 | $exist = self::where('student_id', $student->student_id) |
73 | 73 | ->where('guardian_relation_id', $guardian->guardian_relation_id) |
74 | 74 | ->exists(); |
75 | 75 | |
76 | - $totalGuardians = self::where('student_id',$student->student_id)->count(); |
|
76 | + $totalGuardians = self::where('student_id', $student->student_id)->count(); |
|
77 | 77 | |
78 | 78 | $data = [ |
79 | 79 | 'student_id' => $student->student_id, |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | 'guardian_relation_id' => $guardian->guardian_relation_id, |
82 | 82 | 'created_user_id' => $user |
83 | 83 | ]; |
84 | - if(!$exist){ |
|
84 | + if (!$exist) { |
|
85 | 85 | $data['created'] = now(); |
86 | 86 | self::create($data); |
87 | - }else{ |
|
87 | + }else { |
|
88 | 88 | $data['modified'] = now(); |
89 | - self::where('student_id' , $student->student_id) |
|
90 | - ->where('guardian_relation_id',$guardian->guardian_relation_id) |
|
89 | + self::where('student_id', $student->student_id) |
|
90 | + ->where('guardian_relation_id', $guardian->guardian_relation_id) |
|
91 | 91 | ->update($data); |
92 | 92 | } |
93 | 93 | } |
@@ -68,10 +68,11 @@ discard block |
||
68 | 68 | public static function createStudentGuardian($student,$guardian,$user){ |
69 | 69 | |
70 | 70 | $exist = true; |
71 | - if(!is_null($guardian)) |
|
72 | - $exist = self::where('student_id', $student->student_id) |
|
71 | + if(!is_null($guardian)) { |
|
72 | + $exist = self::where('student_id', $student->student_id) |
|
73 | 73 | ->where('guardian_relation_id', $guardian->guardian_relation_id) |
74 | 74 | ->exists(); |
75 | + } |
|
75 | 76 | |
76 | 77 | $totalGuardians = self::where('student_id',$student->student_id)->count(); |
77 | 78 | |
@@ -84,7 +85,7 @@ discard block |
||
84 | 85 | if(!$exist){ |
85 | 86 | $data['created'] = now(); |
86 | 87 | self::create($data); |
87 | - }else{ |
|
88 | + } else{ |
|
88 | 89 | $data['modified'] = now(); |
89 | 90 | self::where('student_id' , $student->student_id) |
90 | 91 | ->where('guardian_relation_id',$guardian->guardian_relation_id) |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Model; |
6 | 6 | |
7 | -class User_body_mass extends Base_Model { |
|
7 | +class User_body_mass extends Base_Model { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The database table used by the model. |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | protected $dates = ['date', 'modified', 'created']; |
49 | 49 | |
50 | 50 | |
51 | - public static function createOrUpdate($studentId,$row,$file){ |
|
51 | + public static function createOrUpdate($studentId, $row, $file) { |
|
52 | 52 | if (!empty($row['bmi_weight']) && !empty($row['bmi_weight']) && !empty($row['bmi_date_yyyy_mm_dd'])) { |
53 | 53 | try { |
54 | 54 | // convert Meeter to CM |
55 | - $hight = $row['bmi_height'] / 100; |
|
55 | + $hight = $row['bmi_height']/100; |
|
56 | 56 | //calculate BMI |
57 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
57 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
58 | 58 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
59 | 59 | |
60 | - $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id) |
|
61 | - ->where('security_user_id',$studentId)->count(); |
|
60 | + $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id) |
|
61 | + ->where('security_user_id', $studentId)->count(); |
|
62 | 62 | $data = [ |
63 | 63 | 'height' => $row['bmi_height'], |
64 | 64 | 'weight' => $row['bmi_weight'], |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | 'created_user_id' => $file['security_user_id'] |
70 | 70 | ]; |
71 | 71 | // dd($data); |
72 | - if($count == 0){ |
|
72 | + if ($count == 0) { |
|
73 | 73 | self::create($data); |
74 | - }else{ |
|
75 | - self::where('security_user_id',$studentId) |
|
74 | + }else { |
|
75 | + self::where('security_user_id', $studentId) |
|
76 | 76 | ->update($data); |
77 | 77 | } |
78 | - } catch (\Throwable $th) { |
|
79 | - \Log::error('User_body_mass:' . $th->getMessage()); |
|
78 | + }catch (\Throwable $th) { |
|
79 | + \Log::error('User_body_mass:'.$th->getMessage()); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | // dd($data); |
72 | 72 | if($count == 0){ |
73 | 73 | self::create($data); |
74 | - }else{ |
|
74 | + } else{ |
|
75 | 75 | self::where('security_user_id',$studentId) |
76 | 76 | ->update($data); |
77 | 77 | } |
@@ -140,7 +140,7 @@ |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | public static function createOrUpdate($studentId,$params,$file){ |
143 | - return self::create([ |
|
143 | + return self::create([ |
|
144 | 144 | 'student_id' => $studentId, |
145 | 145 | 'institution_class_id' => $params['institution_class']->id, |
146 | 146 | 'education_grade_id' => $params['institution_grade']->education_grade_id, |
@@ -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 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | 'student_status_id' => 1, |
136 | 136 | 'created_user_id' => 1 |
137 | 137 | ]); |
138 | - } catch (\Throwable $th) { |
|
138 | + }catch (\Throwable $th) { |
|
139 | 139 | Log::error($th); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - public static function createOrUpdate($studentId,$params,$file){ |
|
143 | + public static function createOrUpdate($studentId, $params, $file) { |
|
144 | 144 | return self::create([ |
145 | 145 | 'student_id' => $studentId, |
146 | 146 | 'institution_class_id' => $params['institution_class']->id, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | use Maatwebsite\Excel\Concerns\WithMultipleSheets; |
56 | 56 | use Maatwebsite\Excel\Concerns\RegistersEventListeners; |
57 | 57 | |
58 | -class StudentUpdate extends Import implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation , SkipsOnFailure , SkipsOnError{ |
|
58 | +class StudentUpdate extends Import implements ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation, SkipsOnFailure, SkipsOnError{ |
|
59 | 59 | |
60 | 60 | use Importable, |
61 | 61 | RegistersEventListeners, |
@@ -89,30 +89,30 @@ discard block |
||
89 | 89 | $institution = $institutionClass->institution_id; |
90 | 90 | if (!empty($institutionClass)) { |
91 | 91 | $this->setGender($row); |
92 | - $studentInfo = Security_user::createOrUpdateStudentProfile($row,'update',$this->file); |
|
92 | + $studentInfo = Security_user::createOrUpdateStudentProfile($row, 'update', $this->file); |
|
93 | 93 | $student = Institution_class_student::where('student_id', '=', $studentInfo->id)->first(); |
94 | - if(!empty($row['admission_no'])){ |
|
95 | - Institution_student::where('student_id','=',$studentInfo->id) |
|
96 | - ->where('institution_id','=', $institution) |
|
94 | + if (!empty($row['admission_no'])) { |
|
95 | + Institution_student::where('student_id', '=', $studentInfo->id) |
|
96 | + ->where('institution_id', '=', $institution) |
|
97 | 97 | ->update(['admission_id'=> $row['admission_no']]); |
98 | 98 | } |
99 | - User_special_need::createOrUpdate($studentInfo->id,$row,$this->file); |
|
100 | - User_body_mass::createOrUpdate($studentInfo->id,$row,$this->file); |
|
99 | + User_special_need::createOrUpdate($studentInfo->id, $row, $this->file); |
|
100 | + User_body_mass::createOrUpdate($studentInfo->id, $row, $this->file); |
|
101 | 101 | |
102 | - $this->createOrUpdateGuardian($row,$student,'father'); |
|
103 | - $this->createOrUpdateGuardian($row,$student,'mother'); |
|
104 | - $this->createOrUpdateGuardian($row,$student,'guardian'); |
|
102 | + $this->createOrUpdateGuardian($row, $student, 'father'); |
|
103 | + $this->createOrUpdateGuardian($row, $student, 'mother'); |
|
104 | + $this->createOrUpdateGuardian($row, $student, 'guardian'); |
|
105 | 105 | |
106 | 106 | $studentInfo['student_id'] = $studentInfo->id; |
107 | 107 | Institution_student::updateStudentArea($studentInfo->toArray()); |
108 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
108 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
109 | 109 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
110 | 110 | Institution_class::where('id', '=', $institutionClass->id) |
111 | 111 | ->update([ |
112 | 112 | 'total_male_students' => $totalStudents['total_male_students'], |
113 | 113 | 'total_female_students' => $totalStudents['total_female_students']]); |
114 | 114 | } |
115 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
115 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
116 | 116 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
117 | 117 | $failures = $e->failures(); |
118 | 118 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |