Test Setup Failed
Pull Request — master (#651)
by Mohamed
08:18
created
app/Providers/ValidatorExtended.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     protected function ValidateIdentity($attribute, $value, $perameters, $validator)
255 255
 
256 256
     {
257
-       // dd($value);
257
+        // dd($value);
258 258
        
259 259
         foreach ($validator->getData() as $data) {
260 260
            
@@ -263,16 +263,16 @@  discard block
 block discarded – undo
263 263
             {
264 264
                 //dd(true);
265 265
                
266
-               if(!strcmp($data['identity_type'],"BC"))
267
-               {
266
+                if(!strcmp($data['identity_type'],"BC"))
267
+                {
268 268
                     $out = 1;
269
-               }
270
-               else 
271
-               {
272
-                   $out = 2;
273
-               }
269
+                }
270
+                else 
271
+                {
272
+                    $out = 2;
273
+                }
274 274
                
275
-               if(($out == 1)&&(preg_match('/^[0-9]{4}+$/',$value)))
275
+                if(($out == 1)&&(preg_match('/^[0-9]{4}+$/',$value)))
276 276
                 {
277 277
                     //dd(true);
278 278
                     return true;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 }
281 281
                 
282 282
                 elseif (($out == 2) &&(preg_match('/^[0-9]{9}[VX]{1}+$/',$value)))
283
-                 {
283
+                    {
284 284
                     return true;
285 285
                 }
286 286
                 elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/',$value)))
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
                     return true;
289 289
                 }
290 290
                 else {
291
-                   //dd(false);
291
+                    //dd(false);
292 292
                         $this ->_custom_messages['unmatch'] = $attribute." format does not match with Identity type";
293 293
                         $this->_set_custom_stuff();
294 294
                         return false;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
                 }
308 308
                 
309 309
                 elseif (preg_match('/^[0-9]{9}[VX]{1}+$/',$value))
310
-                 {
310
+                    {
311 311
                     return true;
312 312
                 }
313 313
                 elseif (preg_match('/^[0-9]{12}+$/',$value))
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
             if (empty($value)) {
73 73
                 return false;
74 74
             } elseif ($gradeEntity !== null) {
75
-                $admissionAge = (($gradeEntity->admission_age) * 12) - 1;
75
+                $admissionAge = (($gradeEntity->admission_age)*12) - 1;
76 76
                 $to = $academicPeriod->start_date;
77 77
                 $diff_in_months = $to->diffInMonths($value);
78 78
                 $ageOfStudent = $diff_in_months;
79 79
                 $enrolmentMaximumAge = $admissionAge + 120;
80 80
                 return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge);
81
-            } else {
81
+            }else {
82 82
                 return false;
83 83
             }
84
-        } else {
85
-            $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found';
84
+        }else {
85
+            $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found';
86 86
             $this->_set_custom_stuff();
87 87
             return false;
88 88
         }
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
 
94 94
         if (is_numeric($value)) {
95 95
             if ($value < 10) {
96
-                $this->_custom_messages['bmi'] =  $attribute . ' is must greater than 10';
96
+                $this->_custom_messages['bmi'] = $attribute.' is must greater than 10';
97 97
                 $this->_set_custom_stuff();
98 98
                 return false;
99 99
             } elseif ($value > 250) {
100
-                $this->_custom_messages['bmi'] =  $attribute . ' is must smaller than 250';
100
+                $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250';
101 101
                 $this->_set_custom_stuff();
102 102
                 return false;
103 103
             }
104
-        } else {
105
-            $this->_custom_messages['bmi'] =  $attribute . ' is must a valid numeric';
104
+        }else {
105
+            $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric';
106 106
             $this->_set_custom_stuff();
107 107
             return false;
108 108
         }
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 
112 112
     protected function validateBmi($attribute, $value, $parameters)
113 113
     {
114
-        $bmiGrades =  ['G1', 'G4', 'G7', 'G10'];
114
+        $bmiGrades = ['G1', 'G4', 'G7', 'G10'];
115 115
         $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0])
116 116
             ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id')
117 117
             ->first();
118
-        $educationGrade =  Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first();
118
+        $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first();
119 119
         if (in_array($institutionGrade->code, $bmiGrades)) {
120 120
             if (!empty($value)) {
121 121
                 if (($attribute == 'bmi_height') || ('bmi_weight')) {
122 122
                     return $this->validateHW($attribute, $value);
123 123
                 }
124
-            } else {
125
-                $this->_custom_messages['bmi'] =  $attribute . ' is required for ' . $educationGrade->name;
124
+            }else {
125
+                $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name;
126 126
                 $this->_set_custom_stuff();
127 127
                 return false;
128 128
             }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             if (($attribute == 'bmi_height') || ('bmi_weight')) {
131 131
                 return $this->validateHW($attribute, $value);
132 132
             }
133
-        } else {
133
+        }else {
134 134
             return true;
135 135
         }
136 136
     }
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
     {
140 140
         foreach ($validator->getData() as $data) {
141 141
             if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) {
142
-                $BirthDivision = Area_administrative::where('name', '=',  '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); //
142
+                $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); //
143 143
                 if ($BirthDivision->count() > 0) {
144
-                    $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate']
144
+                    $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate']
145 145
                         ->where('parent_id', '=', $BirthDivision->first()->id)->count();
146
-                    return $BirthArea  > 0;
146
+                    return $BirthArea > 0;
147 147
                 } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) {
148 148
                     $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC';
149 149
                     $this->_set_custom_stuff();
150 150
                     return false;
151
-                } else {
151
+                }else {
152 152
                     return true;
153 153
                 }
154
-            } else {
154
+            }else {
155 155
                 return true;
156 156
             }
157 157
         }
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
 
160 160
     protected function validateIsStudentInClass($attribute, $value, $perameters, $validator)
161 161
     {
162
-        $student =  Security_user::where('openemis_no', '=', $value);
162
+        $student = Security_user::where('openemis_no', '=', $value);
163 163
         if ($student->count() > 0) {
164 164
             $student = $student->first()->toArray();
165
-            $check =  Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count();
165
+            $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count();
166 166
             if ($check == 1) {
167 167
                 return true;
168
-            } else {
168
+            }else {
169 169
                 return false;
170 170
             }
171
-        } else {
171
+        }else {
172 172
             return false;
173 173
         }
174 174
     }
175 175
     protected function validateNic($attribute, $value, $perameters, $validator)
176 176
     {
177
-        switch($data['identity_type']){
177
+        switch ($data['identity_type']) {
178 178
             case 'BC':
179 179
                 //inclde the bc validation
180 180
                 break;
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
         }
185 185
         $valid = preg_match('/^([0-9]{9}[VX]|[0-9]{12})$/i', $value);
186 186
         if (!$valid) {
187
-            $this->_custom_messages['nic'] = $attribute . ' is not valid,  Please check the NIC number';
187
+            $this->_custom_messages['nic'] = $attribute.' is not valid,  Please check the NIC number';
188 188
             $this->_set_custom_stuff();
189 189
             return false;
190
-        } else {
190
+        }else {
191 191
             return true;
192 192
         }
193 193
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     protected function validateUserUnique($attribute, $value, $perameters, $validator)
196 196
     {
197 197
         foreach ($validator->getData() as $data) {
198
-            $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
198
+            $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
199 199
             if ($identityType !== null && ($value !== null)) {
200 200
                 if ($identityType->national_code === 'BC') {
201 201
                     return $this->checkUnique($value, $data, $identityType);
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
     protected function validateIsBc($attribute, $value, $perameters, $validator)
212 212
     {
213 213
         foreach ($validator->getData() as $data) {
214
-            $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
214
+            $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
215 215
             if (($identityType !== null) && ($identityType !== "")) {
216 216
                 if (($identityType->national_code) === 'BC') {
217 217
                     return (strlen((string) $data['identity_number']) < 7);
218
-                } else {
218
+                }else {
219 219
                     return true;
220 220
                 }
221
-            } else {
221
+            }else {
222 222
                 return true;
223 223
             }
224 224
         }
@@ -228,24 +228,24 @@  discard block
 block discarded – undo
228 228
     {
229 229
         $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id);
230 230
         if ($isUnique->count() > 0) {
231
-            $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no;
231
+            $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no;
232 232
             $this->_set_custom_stuff();
233 233
             return false;
234
-        } else {
234
+        }else {
235 235
             return true;
236 236
         }
237 237
     }
238 238
 
239 239
     protected function IsBc($data, $value)
240 240
     {
241
-        $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first();
241
+        $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first();
242 242
         if ($identityType !== null) {
243 243
             if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) {
244 244
                 return false;
245
-            } else {
245
+            }else {
246 246
                 return true;
247 247
             }
248
-        } else {
248
+        }else {
249 249
             return true;
250 250
         }
251 251
     }
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
         foreach ($validator->getData() as $data) {
260 260
            
261 261
             
262
-            if(($data['identity_type'] != null)&&($value != null))
262
+            if (($data['identity_type'] != null) && ($value != null))
263 263
             {
264 264
                 //dd(true);
265 265
                
266
-               if(!strcmp($data['identity_type'],"BC"))
266
+               if (!strcmp($data['identity_type'], "BC"))
267 267
                {
268 268
                     $out = 1;
269 269
                }
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
                    $out = 2;
273 273
                }
274 274
                
275
-               if(($out == 1)&&(preg_match('/^[0-9]{4}+$/',$value)))
275
+               if (($out == 1) && (preg_match('/^[0-9]{4}+$/', $value)))
276 276
                 {
277 277
                     //dd(true);
278 278
                     return true;
279 279
     
280 280
                 }
281 281
                 
282
-                elseif (($out == 2) &&(preg_match('/^[0-9]{9}[VX]{1}+$/',$value)))
282
+                elseif (($out == 2) && (preg_match('/^[0-9]{9}[VX]{1}+$/', $value)))
283 283
                  {
284 284
                     return true;
285 285
                 }
286
-                elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/',$value)))
286
+                elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/', $value)))
287 287
                 {
288 288
                     return true;
289 289
                 }
@@ -295,22 +295,22 @@  discard block
 block discarded – undo
295 295
                        
296 296
                 }
297 297
             }
298
-            else if(($data['identity_type'] != null)&&($value == null)){
298
+            else if (($data['identity_type'] != null) && ($value == null)) {
299 299
                 return true;
300 300
             }
301 301
             else {
302
-                if(preg_match('/^[0-9]{4}+$/',$value))
302
+                if (preg_match('/^[0-9]{4}+$/', $value))
303 303
                 {
304 304
                     //dd(true);
305 305
                     return true;
306 306
     
307 307
                 }
308 308
                 
309
-                elseif (preg_match('/^[0-9]{9}[VX]{1}+$/',$value))
309
+                elseif (preg_match('/^[0-9]{9}[VX]{1}+$/', $value))
310 310
                  {
311 311
                     return true;
312 312
                 }
313
-                elseif (preg_match('/^[0-9]{12}+$/',$value))
313
+                elseif (preg_match('/^[0-9]{12}+$/', $value))
314 314
                 {
315 315
                     return true;
316 316
                 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -20 removed lines patch added patch discarded remove patch
@@ -266,8 +266,7 @@  discard block
 block discarded – undo
266 266
                if(!strcmp($data['identity_type'],"BC"))
267 267
                {
268 268
                     $out = 1;
269
-               }
270
-               else 
269
+               } else 
271 270
                {
272 271
                    $out = 2;
273 272
                }
@@ -277,44 +276,34 @@  discard block
 block discarded – undo
277 276
                     //dd(true);
278 277
                     return true;
279 278
     
280
-                }
281
-                
282
-                elseif (($out == 2) &&(preg_match('/^[0-9]{9}[VX]{1}+$/',$value)))
279
+                } elseif (($out == 2) &&(preg_match('/^[0-9]{9}[VX]{1}+$/',$value)))
283 280
                  {
284 281
                     return true;
285
-                }
286
-                elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/',$value)))
282
+                } elseif (($out == 2) && (preg_match('/^[0-9]{12}+$/',$value)))
287 283
                 {
288 284
                     return true;
289
-                }
290
-                else {
285
+                } else {
291 286
                    //dd(false);
292 287
                         $this ->_custom_messages['unmatch'] = $attribute." format does not match with Identity type";
293 288
                         $this->_set_custom_stuff();
294 289
                         return false;
295 290
                        
296 291
                 }
297
-            }
298
-            else if(($data['identity_type'] != null)&&($value == null)){
292
+            } else if(($data['identity_type'] != null)&&($value == null)){
299 293
                 return true;
300
-            }
301
-            else {
294
+            } else {
302 295
                 if(preg_match('/^[0-9]{4}+$/',$value))
303 296
                 {
304 297
                     //dd(true);
305 298
                     return true;
306 299
     
307
-                }
308
-                
309
-                elseif (preg_match('/^[0-9]{9}[VX]{1}+$/',$value))
300
+                } elseif (preg_match('/^[0-9]{9}[VX]{1}+$/',$value))
310 301
                  {
311 302
                     return true;
312
-                }
313
-                elseif (preg_match('/^[0-9]{12}+$/',$value))
303
+                } elseif (preg_match('/^[0-9]{12}+$/',$value))
314 304
                 {
315 305
                     return true;
316
-                }
317
-                else {
306
+                } else {
318 307
                     $this ->_custom_messages['idnum'] = $attribute." format is invalild";
319 308
                     $this->_set_custom_stuff();
320 309
                     return false;
Please login to merge, or discard this patch.
app/Providers/AppServiceProvider.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
      *
26 26
      * @return void
27 27
      */
28
-     public function boot()
29
-     {
30
-         //
31
-         if(!(\App::environment('local'))) {
32
-             URL::forceScheme('https');
33
-         }
34
-     }
28
+        public function boot()
29
+        {
30
+            //
31
+            if(!(\App::environment('local'))) {
32
+                URL::forceScheme('https');
33
+            }
34
+        }
35 35
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      public function boot()
29 29
      {
30 30
          //
31
-         if(!(\App::environment('local'))) {
31
+         if (!(\App::environment('local'))) {
32 32
              URL::forceScheme('https');
33 33
          }
34 34
      }
Please login to merge, or discard this patch.
app/Models/Security_group_institution.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
app/Models/Security_group_user.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
app/Models/Institution_staff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
app/Imports/StudentUpdate.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.