Test Setup Failed
Pull Request — master (#668)
by Mohamed
08:21
created
app/Imports/UsersImport.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
115 115
                 $row = $this->setGender($row);
116 116
                 $mandatorySubject = Institution_class_subject::getMandatorySubjects($this->file['institution_class_id']);
117 117
                 $subjects = getMatchingKeys($row);
118
-                $studentInfo = Security_user::createOrUpdateStudentProfile($row,'create',$this->file);  
118
+                $studentInfo = 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,25 +128,25 @@  discard block
 block discarded – undo
128 128
                     'institution_class' => $institutionClass
129 129
                 ];
130 130
 
131
-                Institution_student_admission::createAdmission($studentInfo->id,$row,$params,$this->file);
132
-                Institution_student::createOrUpdate($studentInfo->id,$row,$params,$this->file);
133
-                $student = Institution_class_student::createOrUpdate($studentInfo->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($studentInfo->id, $row, $params, $this->file);
132
+                Institution_student::createOrUpdate($studentInfo->id, $row, $params, $this->file);
133
+                $student = Institution_class_student::createOrUpdate($studentInfo->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
                 $studentInfo['student_id'] = $studentInfo->id;
142 142
                 Institution_student::updateStudentArea($studentInfo->toArray());
143 143
 
144
-                $this->insertOrUpdateSubjects($row,$student,$institution);
144
+                $this->insertOrUpdateSubjects($row, $student, $institution);
145 145
 
146 146
                 $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']);
147 147
                 if ($totalStudents['total'] > $institutionClass->no_of_students) {
148 148
                     $error = \Illuminate\Validation\ValidationException::withMessages([]);
149
-                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]);
149
+                    $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]);
150 150
                     $failures = [0 => $failure];
151 151
                     throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
152 152
                     Log::info('email-sent', [$this->file]);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 $institutionClass = new Institution_class();
156 156
                 $institutionClass->updateClassCount($this->file);
157 157
             }
158
-        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
158
+        }catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
159 159
             $error = \Illuminate\Validation\ValidationException::withMessages([]);
160 160
             $failures = $e->failures();
161 161
             throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             '*.full_name' => 'required|regex:/^[a-zA-Z .]*$/u|max:256',
171 171
             '*.preferred_name' => 'nullable|regex:/^[a-zA-Z .]*$/u|max:90',
172 172
             '*.gender_mf' => 'required|in:M,F',
173
-            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'],
173
+            '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'],
174 174
             '*.address' => 'nullable',
175 175
             '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place',
176 176
             '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate',
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
             '*.identity_number' => 'nullable|identity:identity_type|required_with:*.identity_type',
180 180
             '*.education_grade' => 'required',
181 181
             '*.option_*' => 'nullable|exists:education_subjects,name',
182
-            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'],
183
-            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'],
182
+            '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'],
183
+            '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'],
184 184
             '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].'
185 185
             '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name',
186 186
             '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/',
Please login to merge, or discard this patch.