@@ -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 | } |
@@ -134,12 +134,12 @@ 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 | } |
141 | 141 | |
142 | - public static function createOrUpdate($studentId,$params,$file){ |
|
142 | + public static function createOrUpdate($studentId, $params, $file) { |
|
143 | 143 | return self::create([ |
144 | 144 | 'student_id' => $studentId, |
145 | 145 | 'institution_class_id' => $params['institution_class']->id, |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public function registerEvents(): array |
76 | 76 | { |
77 | 77 | return [ |
78 | - BeforeSheet::class => function (BeforeSheet $event) { |
|
78 | + BeforeSheet::class => function(BeforeSheet $event) { |
|
79 | 79 | $this->sheetNames[] = $event->getSheet()->getTitle(); |
80 | 80 | $this->worksheet = $event->getSheet(); |
81 | 81 | $this->validateClass(); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
88 | 88 | } |
89 | 89 | }, |
90 | - BeforeImport::class => function (BeforeImport $event) { |
|
90 | + BeforeImport::class => function(BeforeImport $event) { |
|
91 | 91 | $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('C')); |
92 | 92 | if ($this->highestRow < 3) { |
93 | 93 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $row = $this->setGender($row); |
116 | 116 | $mandatorySubject = Institution_class_subject::getMandatorySubjects($this->file['institution_class_id']); |
117 | 117 | $subjects = getMatchingKeys($row); |
118 | - $student = Security_user::createOrUpdateStudentProfile($row,'create',$this->file); |
|
118 | + $student = Security_user::createOrUpdateStudentProfile($row, 'create', $this->file); |
|
119 | 119 | $academicPeriod = Academic_period::where('id', '=', $institutionClass->academic_period_id)->first(); |
120 | 120 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass->id)->first(); |
121 | 121 | $assignee_id = $institutionClass->staff_id ? $institutionClass->staff_id : $this->file['security_user_id']; |
@@ -128,24 +128,24 @@ discard block |
||
128 | 128 | 'institution_class' => $institutionClass |
129 | 129 | ]; |
130 | 130 | |
131 | - Institution_student_admission::createAdmission($student->id,$row,$params,$this->file); |
|
132 | - Institution_student::createOrUpdate($student->id,$row,$params,$this->file); |
|
133 | - $student = Institution_class_student::createOrUpdate($student->id,$params,$this->file); |
|
134 | - User_special_need::createOrUpdate($student->student_id,$row,$this->file); |
|
135 | - User_body_mass::createOrUpdate($student->student_id,$row,$this->file); |
|
131 | + Institution_student_admission::createAdmission($student->id, $row, $params, $this->file); |
|
132 | + Institution_student::createOrUpdate($student->id, $row, $params, $this->file); |
|
133 | + $student = Institution_class_student::createOrUpdate($student->id, $params, $this->file); |
|
134 | + User_special_need::createOrUpdate($student->student_id, $row, $this->file); |
|
135 | + User_body_mass::createOrUpdate($student->student_id, $row, $this->file); |
|
136 | 136 | |
137 | - $this->createOrUpdateGuardian($row,$student,'father'); |
|
138 | - $this->createOrUpdateGuardian($row,$student,'mother'); |
|
139 | - $this->createOrUpdateGuardian($row,$student,'guardian'); |
|
137 | + $this->createOrUpdateGuardian($row, $student, 'father'); |
|
138 | + $this->createOrUpdateGuardian($row, $student, 'mother'); |
|
139 | + $this->createOrUpdateGuardian($row, $student, 'guardian'); |
|
140 | 140 | |
141 | 141 | Institution_student::updateStudentArea($student->toArray()); |
142 | 142 | |
143 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
143 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
144 | 144 | |
145 | 145 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
146 | 146 | if ($totalStudents['total'] > $institutionClass->no_of_students) { |
147 | 147 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
148 | - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); |
|
148 | + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); |
|
149 | 149 | $failures = [0 => $failure]; |
150 | 150 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
151 | 151 | Log::info('email-sent', [$this->file]); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $institutionClass = new Institution_class(); |
155 | 155 | $institutionClass->updateClassCount($this->file); |
156 | 156 | } |
157 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
157 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
158 | 158 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
159 | 159 | $failures = $e->failures(); |
160 | 160 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | '*.full_name' => 'required|regex:/^[a-zA-Z .]*$/u|max:256', |
170 | 170 | '*.preferred_name' => 'nullable|regex:/^[a-zA-Z .]*$/u|max:90', |
171 | 171 | '*.gender_mf' => 'required|in:M,F', |
172 | - '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'], |
|
172 | + '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'], |
|
173 | 173 | '*.address' => 'nullable', |
174 | 174 | '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place', |
175 | 175 | '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate', |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | '*.identity_number' => 'nullable|identity:identity_type|required_with:*.identity_type', |
179 | 179 | '*.education_grade' => 'required', |
180 | 180 | '*.option_*' => 'nullable|exists:education_subjects,name', |
181 | - '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'], |
|
182 | - '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'], |
|
181 | + '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'], |
|
182 | + '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'], |
|
183 | 183 | '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].' |
184 | 184 | '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name', |
185 | 185 | '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/', |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | if (empty($value)) { |
71 | 71 | return false; |
72 | 72 | } elseif ($gradeEntity !== null) { |
73 | - $admissionAge = (($gradeEntity->admission_age) * 12) - 1; |
|
73 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
74 | 74 | $to = $academicPeriod->start_date; |
75 | 75 | $diff_in_months = $to->diffInMonths($value); |
76 | 76 | $ageOfStudent = $diff_in_months; |
77 | 77 | $enrolmentMaximumAge = $admissionAge + 120; |
78 | 78 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
79 | - } else { |
|
79 | + }else { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | - } else { |
|
83 | - $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found'; |
|
82 | + }else { |
|
83 | + $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found'; |
|
84 | 84 | $this->_set_custom_stuff(); |
85 | 85 | return false; |
86 | 86 | } |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | |
92 | 92 | if (is_numeric($value)) { |
93 | 93 | if ($value < 10) { |
94 | - $this->_custom_messages['bmi'] = $attribute . ' is must greater than 10'; |
|
94 | + $this->_custom_messages['bmi'] = $attribute.' is must greater than 10'; |
|
95 | 95 | $this->_set_custom_stuff(); |
96 | 96 | return false; |
97 | 97 | } elseif ($value > 250) { |
98 | - $this->_custom_messages['bmi'] = $attribute . ' is must smaller than 250'; |
|
98 | + $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250'; |
|
99 | 99 | $this->_set_custom_stuff(); |
100 | 100 | return false; |
101 | 101 | } |
102 | - } else { |
|
103 | - $this->_custom_messages['bmi'] = $attribute . ' is must a valid numeric'; |
|
102 | + }else { |
|
103 | + $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric'; |
|
104 | 104 | $this->_set_custom_stuff(); |
105 | 105 | return false; |
106 | 106 | } |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | |
110 | 110 | protected function validateBmi($attribute, $value, $parameters) |
111 | 111 | { |
112 | - $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
112 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
113 | 113 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
114 | 114 | ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
115 | 115 | ->first(); |
116 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
116 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
117 | 117 | if (in_array($institutionGrade->code, $bmiGrades)) { |
118 | 118 | if (!empty($value)) { |
119 | 119 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
120 | 120 | return $this->validateHW($attribute, $value); |
121 | 121 | } |
122 | - } else { |
|
123 | - $this->_custom_messages['bmi'] = $attribute . ' is required for ' . $educationGrade->name; |
|
122 | + }else { |
|
123 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
124 | 124 | $this->_set_custom_stuff(); |
125 | 125 | return false; |
126 | 126 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
129 | 129 | return $this->validateHW($attribute, $value); |
130 | 130 | } |
131 | - } else { |
|
131 | + }else { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | } |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | { |
138 | 138 | foreach ($validator->getData() as $data) { |
139 | 139 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
140 | - $BirthDivision = Area_administrative::where('name', '=', '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); // |
|
140 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
141 | 141 | if ($BirthDivision->count() > 0) { |
142 | - $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
142 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
143 | 143 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
144 | - return $BirthArea > 0; |
|
144 | + return $BirthArea > 0; |
|
145 | 145 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
146 | 146 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
147 | 147 | $this->_set_custom_stuff(); |
148 | 148 | return false; |
149 | - } else { |
|
149 | + }else { |
|
150 | 150 | return true; |
151 | 151 | } |
152 | - } else { |
|
152 | + }else { |
|
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | } |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | |
158 | 158 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) |
159 | 159 | { |
160 | - $student = Security_user::where('openemis_no', '=', $value); |
|
160 | + $student = Security_user::where('openemis_no', '=', $value); |
|
161 | 161 | if ($student->count() > 0) { |
162 | 162 | $student = $student->first()->toArray(); |
163 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
163 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
164 | 164 | if ($check == 1) { |
165 | 165 | return true; |
166 | - } else { |
|
166 | + }else { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | - } else { |
|
169 | + }else { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | { |
178 | 178 | $valid = true; |
179 | 179 | foreach ($validator->getData() as $data) { |
180 | - switch($data[$perameters[0]]){ |
|
180 | + switch ($data[$perameters[0]]) { |
|
181 | 181 | case 'BC': |
182 | 182 | $valid = preg_match('/^([0-9]{11,12})/i', $value); |
183 | 183 | break; |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | if ($valid == 0) { |
193 | - dd($data[$perameters[0]],$valid,$value); |
|
194 | - $this->_custom_messages['identity'] = $attribute . ' is not valid Please check the NIC number'; |
|
193 | + dd($data[$perameters[0]], $valid, $value); |
|
194 | + $this->_custom_messages['identity'] = $attribute.' is not valid Please check the NIC number'; |
|
195 | 195 | $this->_set_custom_stuff(); |
196 | 196 | return false; |
197 | - } else { |
|
197 | + }else { |
|
198 | 198 | return true; |
199 | 199 | } |
200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | protected function validateUserUnique($attribute, $value, $perameters, $validator) |
203 | 203 | { |
204 | 204 | foreach ($validator->getData() as $data) { |
205 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
205 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
206 | 206 | if ($identityType !== null && ($value !== null)) { |
207 | 207 | if ($identityType->national_code === 'BC') { |
208 | 208 | return $this->checkUnique($value, $data, $identityType); |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | protected function validateIsBc($attribute, $value, $perameters, $validator) |
219 | 219 | { |
220 | 220 | foreach ($validator->getData() as $data) { |
221 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
221 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
222 | 222 | if (($identityType !== null) && ($identityType !== "")) { |
223 | 223 | if (($identityType->national_code) === 'BC') { |
224 | 224 | return (strlen((string) $data['identity_number']) < 7); |
225 | - } else { |
|
225 | + }else { |
|
226 | 226 | return true; |
227 | 227 | } |
228 | - } else { |
|
228 | + }else { |
|
229 | 229 | return true; |
230 | 230 | } |
231 | 231 | } |
@@ -235,24 +235,24 @@ discard block |
||
235 | 235 | { |
236 | 236 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
237 | 237 | if ($isUnique->count() > 0) { |
238 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
238 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
239 | 239 | $this->_set_custom_stuff(); |
240 | 240 | return false; |
241 | - } else { |
|
241 | + }else { |
|
242 | 242 | return true; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | 246 | protected function IsBc($data, $value) |
247 | 247 | { |
248 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
248 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
249 | 249 | if ($identityType !== null) { |
250 | 250 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
251 | 251 | return false; |
252 | - } else { |
|
252 | + }else { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | - } else { |
|
255 | + }else { |
|
256 | 256 | return true; |
257 | 257 | } |
258 | 258 | } |
@@ -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); |