@@ -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,29 +89,29 @@ 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 | Institution_student::updateStudentArea($student->toArray()); |
107 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
107 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
108 | 108 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
109 | 109 | Institution_class::where('id', '=', $institutionClass->id) |
110 | 110 | ->update([ |
111 | 111 | 'total_male_students' => $totalStudents['total_male_students'], |
112 | 112 | 'total_female_students' => $totalStudents['total_female_students']]); |
113 | 113 | } |
114 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
114 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
115 | 115 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
116 | 116 | $failures = $e->failures(); |
117 | 117 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -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 | } |
@@ -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 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public static function boot() |
72 | 72 | { |
73 | 73 | parent::boot(); |
74 | - self::creating(function ($model) { |
|
74 | + self::creating(function($model) { |
|
75 | 75 | $model->id = (string) Uuid::generate(4); |
76 | 76 | $model->created = now(); |
77 | 77 | }); |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | 'institution_students.admission_id' |
130 | 130 | ) |
131 | 131 | ->where('institution_students.institution_id', $institutionGrade['institution_id']) |
132 | - ->where('institution_students.student_status_id',1) |
|
132 | + ->where('institution_students.student_status_id', 1) |
|
133 | 133 | ->where('institution_students.education_grade_id', $institutionGrade['education_grade_id']) |
134 | - ->where('institution_students.deleted_at',null) |
|
134 | + ->where('institution_students.deleted_at', null) |
|
135 | 135 | ->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray(); |
136 | 136 | } |
137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public static function createExaminationData($student, $admissionInfo) |
146 | 146 | { |
147 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
147 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
148 | 148 | try { |
149 | 149 | self::create([ |
150 | 150 | 'id' => (string) Uuid::generate(4), |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | 'created' => now(), |
170 | 170 | 'created_user_id' => 1 |
171 | 171 | ]); |
172 | - } catch (\Throwable $th) { |
|
172 | + }catch (\Throwable $th) { |
|
173 | 173 | Log::error($th); |
174 | 174 | } |
175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public static function updateExaminationData($student, $admissionInfo) |
185 | 185 | { |
186 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
186 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
187 | 187 | try { |
188 | 188 | self::where([ |
189 | 189 | 'student_id' => $student['student_id'], |
@@ -204,56 +204,56 @@ discard block |
||
204 | 204 | 'modified_user_id' => 1 |
205 | 205 | ] |
206 | 206 | ); |
207 | - } catch (\Throwable $th) { |
|
207 | + }catch (\Throwable $th) { |
|
208 | 208 | Log::error($th); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - public static function updateStudentArea(array $student){ |
|
213 | - $father = Student_guardian::where('student_id',$student['student_id']) |
|
214 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
215 | - ->where('guardian_relation_id',1) |
|
212 | + public static function updateStudentArea(array $student) { |
|
213 | + $father = Student_guardian::where('student_id', $student['student_id']) |
|
214 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
215 | + ->where('guardian_relation_id', 1) |
|
216 | 216 | ->get()->first(); |
217 | 217 | |
218 | - $mother = Student_guardian::where('student_id',$student['student_id']) |
|
219 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
220 | - ->where('guardian_relation_id',2) |
|
218 | + $mother = Student_guardian::where('student_id', $student['student_id']) |
|
219 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
220 | + ->where('guardian_relation_id', 2) |
|
221 | 221 | ->get()->first(); |
222 | 222 | |
223 | - $guardian = Student_guardian::where('student_id',$student['student_id']) |
|
224 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
225 | - ->where('guardian_relation_id',3) |
|
223 | + $guardian = Student_guardian::where('student_id', $student['student_id']) |
|
224 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
225 | + ->where('guardian_relation_id', 3) |
|
226 | 226 | ->get()->first(); |
227 | 227 | |
228 | - if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
|
229 | - Security_user::where('id',$student['student_id']) |
|
228 | + if (!is_null($father) && is_null($mother) && is_null($guardian)) { |
|
229 | + Security_user::where('id', $student['student_id']) |
|
230 | 230 | ->update(['address_area_id' => $father->address_area_id]); |
231 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
232 | - Security_user::where('id',$student['student_id']) |
|
231 | + }elseif (!is_null($mother) && (is_null($father) && is_null($guardian))) { |
|
232 | + Security_user::where('id', $student['student_id']) |
|
233 | 233 | ->update(['address_area_id' => $mother->address_area_id]); |
234 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
235 | - Security_user::where('id',$student['student_id']) |
|
234 | + }elseif (!is_null($guardian) && is_null($father) && is_null($mother)) { |
|
235 | + Security_user::where('id', $student['student_id']) |
|
236 | 236 | ->update(['address_area_id' => $guardian->address_area_id]); |
237 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
237 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) { |
|
238 | 238 | // dd($father->address_area_id,$mother->address_area_id,$student['student_id']); |
239 | - $d = Security_user::where('id',$student['student_id']) |
|
239 | + $d = Security_user::where('id', $student['student_id']) |
|
240 | 240 | ->update(['address_area_id' => $mother->address_area_id]); |
241 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
242 | - Security_user::where('id',$student['student_id']) |
|
241 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) { |
|
242 | + Security_user::where('id', $student['student_id']) |
|
243 | 243 | ->update(['address_area_id' => $guardian->address_area_id]); |
244 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
245 | - Security_user::where('id',$student['student_id']) |
|
244 | + }elseif (!is_null($father) && $father->address == $student['address']) { |
|
245 | + Security_user::where('id', $student['student_id']) |
|
246 | 246 | ->update(['address_area_id' => $guardian->address_area_id]); |
247 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
248 | - Security_user::where('id',$student['student_id']) |
|
247 | + }elseif (!is_null($mother) && $mother->address == $student['address']) { |
|
248 | + Security_user::where('id', $student['student_id']) |
|
249 | 249 | ->update(['address_area_id' => $mother->address_area_id]); |
250 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
251 | - Security_user::where('id',$student['student_id']) |
|
250 | + }elseif (!is_null($guardian) && $guardian->address == $student['address']) { |
|
251 | + Security_user::where('id', $student['student_id']) |
|
252 | 252 | ->update(['address_area_id' => $guardian->address_area_id]); |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - public static function createOrUpdate($studentId,$row,$params,$file){ |
|
256 | + public static function createOrUpdate($studentId, $row, $params, $file) { |
|
257 | 257 | self::create([ |
258 | 258 | 'student_status_id' => 1, |
259 | 259 | 'student_id' => $studentId, |
@@ -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 | } |
@@ -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 getMandatorySubjects($institutionClass){ |
|
76 | + public static function getMandatorySubjects($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 | }) |
84 | 84 | ->where('institution_class_id', '=', $institutionClass) |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | return $mandatorySubject; |
87 | 87 | } |
88 | 88 | |
89 | - public static function getAllSubjects($institutionClass){ |
|
89 | + public static function getAllSubjects($institutionClass) { |
|
90 | 90 | $allSubjects = Institution_class_subject::with(['institutionSubject']) |
91 | - ->whereHas('institutionSubject', function ($query) use ($institutionClass) { |
|
91 | + ->whereHas('institutionSubject', function($query) use ($institutionClass) { |
|
92 | 92 | $query->whereHas('institutionGradeSubject')->where('education_grade_id', $institutionClass['education_grade_id']); |
93 | 93 | }) |
94 | 94 | ->where('institution_class_id', '=', $institutionClass['id']) |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | $data = []; |
101 | 101 | foreach ($subjects as $subject) { |
102 | 102 | $subjectId = Institution_class_subject::with(['institutionSubject']) |
103 | - ->whereHas('institutionSubject', function ($query) use ($row, $subject, $student) { |
|
104 | - $query->whereHas('institutionGradeSubject',function($query){ |
|
105 | - $query->where('auto_allocation',0); |
|
103 | + ->whereHas('institutionSubject', function($query) use ($row, $subject, $student) { |
|
104 | + $query->whereHas('institutionGradeSubject', function($query) { |
|
105 | + $query->where('auto_allocation', 0); |
|
106 | 106 | }) |
107 | 107 | ->where('name', '=', $row[$subject]) |
108 | 108 | ->where('education_grade_id', '=', $student->education_grade_id); |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | return $data; |
116 | 116 | } |
117 | 117 | |
118 | - public function getInstitutionClassSubjects($academicPeriodId,$classIds){ |
|
118 | + public function getInstitutionClassSubjects($academicPeriodId, $classIds) { |
|
119 | 119 | return self::query() |
120 | - ->whereIn('institution_class_id',$classIds) |
|
120 | + ->whereIn('institution_class_id', $classIds) |
|
121 | 121 | ->get() |
122 | 122 | ->toArray(); |
123 | 123 | } |
124 | 124 | |
125 | - public function isDuplicated($subject){ |
|
126 | - return self::query()->where('institution_subject_id',$subject['institution_subject_id']) |
|
127 | - ->where('institution_class_id',$subject['institution_class_id'])->get()->toArray(); |
|
125 | + public function isDuplicated($subject) { |
|
126 | + return self::query()->where('institution_subject_id', $subject['institution_subject_id']) |
|
127 | + ->where('institution_class_id', $subject['institution_class_id'])->get()->toArray(); |
|
128 | 128 | } |
129 | 129 | } |
@@ -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 | } |
@@ -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, |