@@ -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 |
@@ -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, |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | break; |
111 | 111 | } |
112 | 112 | |
113 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
114 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
115 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
113 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
114 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
115 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
116 | 116 | //$academicPeriod = Academic_period::where('name', '=', $institutionClass->academic_period_id)->first(); |
117 | 117 | //$academicPeriod = Academic_period::where('name', '=',$row['academic_period'])->first(); |
118 | 118 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | ->update(['admission_id'=> $row['admission_no']]); |
162 | 162 | }*/ |
163 | 163 | |
164 | - if(!empty($row['admission_no'])){ |
|
165 | - Institution_student::where('student_id','=',$studentInfo->id) |
|
166 | - ->where('institution_id','=', $institution) |
|
164 | + if (!empty($row['admission_no'])) { |
|
165 | + Institution_student::where('student_id', '=', $studentInfo->id) |
|
166 | + ->where('institution_id', '=', $institution) |
|
167 | 167 | // ->where('academic_period_id','=',$academicPeriod->id) |
168 | 168 | ->update(['admission_id'=> $row['admission_no']]); |
169 | 169 | } |
@@ -189,17 +189,17 @@ discard block |
||
189 | 189 | if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) { |
190 | 190 | |
191 | 191 | // convert Meeter to CM |
192 | - $hight = $row['bmi_height'] / 100; |
|
192 | + $hight = $row['bmi_height']/100; |
|
193 | 193 | |
194 | 194 | //calculate BMI |
195 | - $bodyMass = ($row['bmi_weight']) / pow($hight, 2); |
|
195 | + $bodyMass = ($row['bmi_weight'])/pow($hight, 2); |
|
196 | 196 | |
197 | 197 | $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first(); |
198 | - $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id ) |
|
199 | - ->where('security_user_id','=',$student->student_id)->count(); |
|
198 | + $count = User_body_mass::where('academic_period_id', '=', $bmiAcademic->id) |
|
199 | + ->where('security_user_id', '=', $student->student_id)->count(); |
|
200 | 200 | |
201 | 201 | \Log::debug('User_body_mass'); |
202 | - if(!($count > 0)){ |
|
202 | + if (!($count > 0)) { |
|
203 | 203 | User_body_mass::create([ |
204 | 204 | 'height' => $row['bmi_height'], |
205 | 205 | 'weight' => $row['bmi_weight'], |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) { |
216 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first(); |
|
217 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first(); |
|
218 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first(); |
|
219 | - $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
216 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['fathers_address_area'].'%')->first(); |
|
217 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['fathers_nationality'].'%')->first(); |
|
218 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['fathers_identity_type'].'%')->first(); |
|
219 | + $openemisFather = $this->uniqueUid::getUniqueAlphanumeric(); |
|
220 | 220 | |
221 | 221 | $identityType = ($identityType !== null) ? $identityType->id : null; |
222 | 222 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | if ($father === null) { |
232 | 232 | $data = [ |
233 | - 'username' => str_replace('-','',$openemisFather), |
|
233 | + 'username' => str_replace('-', '', $openemisFather), |
|
234 | 234 | 'openemis_no' => $openemisFather, |
235 | 235 | 'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
236 | 236 | 'last_name' => genNameWithInitials($row['fathers_full_name']), |
@@ -249,25 +249,25 @@ discard block |
||
249 | 249 | $father['guardian_relation_id'] = 1; |
250 | 250 | if (array_key_exists('fathers_phone', $row)) { |
251 | 251 | $father['contact'] = $row['fathers_phone']; |
252 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
252 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
253 | 253 | } |
254 | 254 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
255 | - } else { |
|
255 | + }else { |
|
256 | 256 | Security_user::where('id', '=', $father->id) |
257 | 257 | ->update(['is_guardian' => 1]); |
258 | 258 | $father['guardian_relation_id'] = 1; |
259 | 259 | if (array_key_exists('fathers_phone', $row)) { |
260 | 260 | $father['contact'] = $row['fathers_phone']; |
261 | - User_contact::createOrUpdate($father,$this->file['security_user_id']); |
|
261 | + User_contact::createOrUpdate($father, $this->file['security_user_id']); |
|
262 | 262 | } |
263 | 263 | Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']); |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | 267 | if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) { |
268 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first(); |
|
269 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first(); |
|
270 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first(); |
|
268 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['mothers_address_area'].'%')->first(); |
|
269 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['mothers_nationality'].'%')->first(); |
|
270 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['mothers_identity_type'].'%')->first(); |
|
271 | 271 | $openemisMother = $this->uniqueUid::getUniqueAlphanumeric(); |
272 | 272 | |
273 | 273 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | if ($mother === null) { |
284 | 284 | $mother = Security_user::create([ |
285 | - 'username' => str_replace('-','',$openemisMother), |
|
285 | + 'username' => str_replace('-', '', $openemisMother), |
|
286 | 286 | 'openemis_no' => $openemisMother, |
287 | 287 | 'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
288 | 288 | 'last_name' => genNameWithInitials($row['mothers_full_name']), |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | $mother['guardian_relation_id'] = 2; |
301 | 301 | if (array_key_exists('mothers_phone', $row)) { |
302 | 302 | $mother['contact'] = $row['mothers_phone']; |
303 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
303 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
304 | 304 | } |
305 | 305 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
306 | - } else { |
|
306 | + }else { |
|
307 | 307 | Security_user::where('id', '=', $mother->id) |
308 | 308 | ->update(['is_guardian' => 1]); |
309 | 309 | $mother['guardian_relation_id'] = 2; |
310 | 310 | if (array_key_exists('mothers_phone', $row)) { |
311 | 311 | $mother['contact'] = $row['mothers_phone']; |
312 | - User_contact::createOrUpdate($mother,$this->file['security_user_id']); |
|
312 | + User_contact::createOrUpdate($mother, $this->file['security_user_id']); |
|
313 | 313 | } |
314 | 314 | Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']); |
315 | 315 | } |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | |
319 | 319 | if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) { |
320 | 320 | $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2; |
321 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first(); |
|
322 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first(); |
|
323 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first(); |
|
321 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row['guardians_address_area'].'%')->first(); |
|
322 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['guardians_nationality'].'%')->first(); |
|
323 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['guardians_identity_type'].'%')->first(); |
|
324 | 324 | $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric(); |
325 | 325 | |
326 | 326 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | if ($guardian === null) { |
337 | 337 | $guardian = Security_user::create([ |
338 | - 'username' => str_replace('-','',$openemisGuardian), |
|
338 | + 'username' => str_replace('-', '', $openemisGuardian), |
|
339 | 339 | 'openemis_no' => $openemisGuardian, |
340 | 340 | 'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
341 | 341 | 'last_name' => genNameWithInitials($row['guardians_full_name']), |
@@ -354,23 +354,23 @@ discard block |
||
354 | 354 | $guardian['guardian_relation_id'] = 3; |
355 | 355 | if (array_key_exists('guardians_phone', $row)) { |
356 | 356 | $guardian['contact'] = $row['guardians_phone']; |
357 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
357 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
358 | 358 | } |
359 | 359 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
360 | - } else { |
|
360 | + }else { |
|
361 | 361 | Security_user::where('id', '=', $guardian->id) |
362 | 362 | ->update(['is_guardian' => 1]); |
363 | 363 | $guardian['guardian_relation_id'] = 3; |
364 | 364 | if (array_key_exists('guardians_phone', $row)) { |
365 | 365 | $guardian['contact'] = $row['guardians_phone']; |
366 | - User_contact::createOrUpdate($guardian,$this->file['security_user_id']); |
|
366 | + User_contact::createOrUpdate($guardian, $this->file['security_user_id']); |
|
367 | 367 | } |
368 | 368 | Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']); |
369 | 369 | } |
370 | 370 | } |
371 | 371 | Institution_student::updateStudentArea($student); |
372 | 372 | |
373 | - $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
373 | + $optionalSubjects = Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution); |
|
374 | 374 | |
375 | 375 | $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject); |
376 | 376 | // $stundetSubjects = $this->getStudentSubjects($student); |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | if (!empty($allSubjects)) { |
380 | 380 | $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id'); |
381 | 381 | $this->student = $student; |
382 | - $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects); |
|
382 | + $allSubjects = array_map(array($this, 'setStudentSubjects'), $allSubjects); |
|
383 | 383 | // $allSubjects = array_unique($allSubjects,SORT_REGULAR); |
384 | 384 | $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id'); |
385 | - array_walk($allSubjects,array($this,'insertSubject')); |
|
385 | + array_walk($allSubjects, array($this, 'insertSubject')); |
|
386 | 386 | array_walk($allSubjects, array($this, 'updateSubjectCount')); |
387 | 387 | } |
388 | 388 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | 'total_male_students' => $totalStudents['total_male_students'], |
396 | 396 | 'total_female_students' => $totalStudents['total_female_students']]); |
397 | 397 | } |
398 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
398 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
399 | 399 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
400 | 400 | $failures = $e->failures(); |
401 | 401 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |