Test Setup Failed
Pull Request — master (#478)
by Mohamed
13:16
created

StudentUpdate   C

Complexity

Total Complexity 55

Size/Duplication

Total Lines 384
Duplicated Lines 0 %

Importance

Changes 5
Bugs 4 Features 0
Metric Value
eloc 273
c 5
b 4
f 0
dl 0
loc 384
rs 6
wmc 55

5 Methods

Rating   Name   Duplication   Size   Complexity  
A sheets() 0 3 1
F model() 0 303 51
A rules() 0 46 1
A getStudentSubjects() 0 3 1
A registerEvents() 0 8 1

How to fix   Complexity   

Complex Class

Complex classes like StudentUpdate often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use StudentUpdate, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace App\Imports;
4
5
use App\Models\User;
6
use function foo\func;
7
use App\Models\Nationality;
8
use App\Rules\admissionAge;
9
use App\Models\User_contact;
10
use App\Models\Identity_type;
11
use App\Models\Security_user;
12
use App\Models\User_identity;
13
use App\Models\Import_mapping;
14
use App\Models\Security_group;
15
use App\Models\User_body_mass;
16
use App\Models\Academic_period;
17
use App\Models\Student_guardian;
18
use App\Models\User_nationality;
19
use App\Models\Institution_class;
20
use App\Models\User_special_need;
21
use App\Mail\StudentCountExceeded;
22
use App\Mail\StudentImportSuccess;
23
use Illuminate\Support\Facades\DB;
24
use App\Models\Area_administrative;
25
use App\Models\Institution_student;
26
use App\Models\Institution_subject;
27
use App\Models\Workflow_transition;
28
use Illuminate\Support\Facades\Log;
29
use Illuminate\Support\Facades\Mail;
30
use App\Models\Institution_class_grade;
31
use App\Models\Special_need_difficulty;
32
use Illuminate\Support\Facades\Request;
33
use Maatwebsite\Excel\Concerns\ToModel;
34
use App\Models\Education_grades_subject;
35
use App\Models\Institution_class_student;
36
use App\Models\Institution_class_subject;
37
use Illuminate\Support\Facades\Validator;
38
use Maatwebsite\Excel\Concerns\WithLimit;
39
use Maatwebsite\Excel\Events\BeforeSheet;
40
use Maatwebsite\Excel\Validators\Failure;
41
use Maatwebsite\Excel\Concerns\Importable;
42
use Maatwebsite\Excel\Concerns\WithEvents;
43
use Maatwebsite\Excel\Events\BeforeImport;
44
use App\Models\Institution_subject_student;
45
use Maatwebsite\Excel\Concerns\SkipsErrors;
46
use Maatwebsite\Excel\Concerns\WithMapping;
47
use Maatwebsite\Excel\Concerns\SkipsOnError;
48
use Maatwebsite\Excel\Concerns\WithStartRow;
49
use App\Models\Institution_student_admission;
50
use Maatwebsite\Excel\Concerns\SkipsFailures;
51
use Maatwebsite\Excel\Concerns\SkipsOnFailure;
52
use Maatwebsite\Excel\Concerns\WithHeadingRow;
53
use Maatwebsite\Excel\Concerns\WithValidation;
54
use Maatwebsite\Excel\Concerns\WithBatchInserts;
55
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
56
use Maatwebsite\Excel\Concerns\RegistersEventListeners;
57
58
class StudentUpdate extends Import implements  ToModel, WithStartRow, WithHeadingRow, WithMultipleSheets, WithEvents, WithMapping, WithLimit, WithBatchInserts, WithValidation , SkipsOnFailure , SkipsOnError{
59
60
    use Importable,
0 ignored issues
show
introduced by
The trait Maatwebsite\Excel\Concerns\Importable requires some properties which are not provided by App\Imports\StudentUpdate: $disk, $readerType, $filePath
Loading history...
61
        RegistersEventListeners,
62
        SkipsFailures,
63
        SkipsErrors;
64
65
66
    public function sheets(): array {
67
        return [
68
            'Update Students' => $this
69
        ];
70
    }
71
72
    public function registerEvents(): array {
73
        // TODO: Implement registerEvents() method.
74
        return [
75
            BeforeSheet::class => function(BeforeSheet $event) {
76
                $this->sheetNames[] = $event->getSheet()->getTitle();
0 ignored issues
show
Bug Best Practice introduced by
The property sheetNames does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
77
                $this->worksheet = $event->getSheet();
0 ignored issues
show
Bug Best Practice introduced by
The property worksheet does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
78
                $worksheet = $event->getSheet();
79
                $this->highestRow = $worksheet->getHighestDataRow('B');
0 ignored issues
show
Bug Best Practice introduced by
The property highestRow does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
80
            }
81
        ];
82
    }
83
84
85
    public function model(array $row) {
86
87
        try {
88
            $institutionClass = Institution_class::find($this->file['institution_class_id']);
89
            $institution = $institutionClass->institution_id;
0 ignored issues
show
Bug introduced by
The property institution_id does not exist on App\Models\Institution_class. Did you mean institution?
Loading history...
90
91
92
            if (!array_filter($row)) {
93
                return null;
94
            }
95
96
            if (!empty($institutionClass)) {
97
                $mandatorySubject = Institution_class_subject::getMandetorySubjects($this->file['institution_class_id']);
98
                $subjects = getMatchingKeys($row);
99
                $genderId = null;
100
                switch ($row['gender_mf']) {
101
                    case 'M':
102
                        $row['gender_mf'] = 1;
103
                        $this->maleStudentsCount += 1;
104
                        break;
105
                    case 'F':
106
                        $row['gender_mf'] = 2;
107
                        $this->femaleStudentsCount += 1;
108
                        break;
109
                }
110
111
                $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first();
112
                $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first();
113
                $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first();
114
                $academicPeriod = Academic_period::where('name', '=', $row['academic_period'])->first();
115
116
117
                $date = $row['date_of_birth_yyyy_mm_dd'];
118
119
                $identityType = $identityType !== null ? $identityType->id : null;
120
                $nationalityId = $nationalityId !== null ? $nationalityId->id : null;
121
122
                $BirthArea = $BirthArea !== null ? $BirthArea->id : null;
123
                $identityNUmber = $row['identity_number'];
124
125
                //create students data
126
                \Log::debug('Security_user');
127
128
                $studentInfo = Security_user::where('openemis_no', '=', $row['student_id'])->first();
129
                Security_user::where('openemis_no', $studentInfo['openemis_no'])
130
                        ->update([
131
                            '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.
132
                            'last_name' => $row['full_name'] ? genNameWithInitials($row['full_name']) : genNameWithInitials($studentInfo['first_name']),
133
                            'gender_id' => $genderId ? $genderId : $studentInfo['gender_id'],
0 ignored issues
show
introduced by
$genderId is of type null, thus it always evaluated to false.
Loading history...
134
                            'date_of_birth' => $date ? $date : $studentInfo['date_of_birth'],
135
                            'address' => $row['address'] ? $row['address'] : $studentInfo['address'],
136
                            'birthplace_area_id' => $row['birth_registrar_office_as_in_birth_certificate'] ? $BirthArea : $studentInfo['birthplace_area_id'],
137
                            'nationality_id' => $row['nationality'] ? $nationalityId : $studentInfo['nationality_id'],
138
                            'identity_type_id' => $row['identity_type'] ? $identityType : $studentInfo['identity_type_id'],
139
                            'identity_number' => $row['identity_number'] ? $identityNUmber : $studentInfo['identity_number'],
140
                            'is_student' => 1,
141
                            'modified' => now(),
142
                            'modified_user_id' => $this->file['security_user_id']
143
                            ]);
144
145
                $student = Institution_class_student::where('student_id', '=', $studentInfo->id)->first();
146
147
                if(!empty($row['admission_no']) && !empty($academicPeriod)){
148
                    Institution_student::where('student_id','=',$studentInfo->id)
149
                    ->where('institution_id','=', $institution)
150
                    ->where('academic_period_id','=',$academicPeriod->id)
151
                    ->update(['admission_id'=> $row['admission_no']]);
152
                }
153
                
154
                if (!empty($row['special_need'])) {
155
156
                    $specialNeed = Special_need_difficulty::where('name', '=', $row['special_need'])->first();
157
                    $data = [
158
                        'special_need_date' => now(),
159
                        'security_user_id' => $student->student_id,
0 ignored issues
show
Bug introduced by
The property student_id does not exist on App\Models\Institution_class_student. Did you mean student?
Loading history...
160
                        'special_need_type_id' => 1,
161
                        'special_need_difficulty_id' => $specialNeed->id,
162
                        'created_user_id' => $this->file['security_user_id']
163
                    ];
164
165
                    $check = User_special_need::isDuplicated($data);
166
                    if ($check) {
167
                        User_special_need::create($data);
168
                    }
169
                }
170
171
172
173
                if (!empty($row['bmi_height']) && (!empty($row['bmi_weight']))) {
174
175
                    // convert Meeter to CM
176
                    $hight = $row['bmi_height'] / 100;
177
178
                    //calculate BMI
179
                    $bodyMass = ($row['bmi_weight']) / pow($hight, 2);
180
181
                    $bmiAcademic = Academic_period::where('name', '=', $row['bmi_academic_period'])->first();
182
                    $count = User_body_mass::where('academic_period_id' ,'=',$bmiAcademic->id )
183
                            ->where('security_user_id','=',$student->student_id)->count();
184
185
                    \Log::debug('User_body_mass');
186
                    if(!($count > 0)){
187
                        User_body_mass::create([
188
                            'height' => $row['bmi_height'],
189
                            'weight' => $row['bmi_weight'],
190
                            'date' => $row['bmi_date_yyyy_mm_dd'],
191
                            'body_mass_index' => $bodyMass,
192
                            'academic_period_id' => $bmiAcademic->id,
193
                            'security_user_id' => $student->student_id,
194
                            'created_user_id' => $this->file['security_user_id']
195
                        ]);
196
                    }
197
                }
198
199
                if (!empty($row['fathers_full_name']) && ($row['fathers_date_of_birth_yyyy_mm_dd'] !== null)) {
200
                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['fathers_address_area'] . '%')->first();
201
                    $nationalityId = Nationality::where('name', 'like', '%' . $row['fathers_nationality'] . '%')->first();
202
                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['fathers_identity_type'] . '%')->first();
203
                    $openemisFather =  $this->uniqueUid::getUniqueAlphanumeric();
204
205
                    $identityType = ($identityType !== null) ? $identityType->id : null;
206
                    $nationalityId = $nationalityId !== null ? $nationalityId->id : null;
207
208
                    $father = null;
209
                    if (!empty($row['fathers_identity_number'])) {
210
                        $father = Security_user::where('identity_type_id', '=', $nationalityId)
211
                                        ->where('identity_number', '=', $row['fathers_identity_number'])->first();
212
                    }
213
214
215
                    if ($father === null) {
216
                        $data = [
217
                            'username' => str_replace('-','',$openemisFather),
218
                            'openemis_no' => $openemisFather,
219
                            'first_name' => $row['fathers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
220
                            'last_name' => genNameWithInitials($row['fathers_full_name']),
221
                            'gender_id' => 1,
222
                            'date_of_birth' => $row['fathers_date_of_birth_yyyy_mm_dd'],
223
                            'address' => $row['fathers_address'],
224
                            'address_area_id' => $AddressArea->id,
225
                            'nationality_id' => $nationalityId,
226
                            'identity_type_id' => $identityType,
227
                            'identity_number' => $row['fathers_identity_number'],
228
                            'is_guardian' => 1,
229
                            'created_user_id' => $this->file['security_user_id']
230
                        ];
231
                        $father = Security_user::create($data);
232
                             
233
                        $father['guardian_relation_id'] = 1;
234
                        if (array_key_exists('fathers_phone', $row)) {
235
                            $father['contact'] = $row['fathers_phone'];
236
                            User_contact::createOrUpdate($father,$this->file['security_user_id']);
237
                        }
238
                        Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
239
                    } else {
240
                        Security_user::where('id', '=', $father->id)
241
                                ->update(['is_guardian' => 1]);
242
                        $father['guardian_relation_id'] = 1;
243
                        if (array_key_exists('fathers_phone', $row)) {
244
                            $father['contact'] = $row['fathers_phone'];
245
                            User_contact::createOrUpdate($father,$this->file['security_user_id']);
246
                        }
247
                        Student_guardian::createStudentGuardian($student, $father, $this->file['security_user_id']);
248
                    }
249
                }
250
251
                if (!empty($row['mothers_full_name']) && ($row['mothers_date_of_birth_yyyy_mm_dd'] !== null)) {
252
                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['mothers_address_area'] . '%')->first();
253
                    $nationalityId = Nationality::where('name', 'like', '%' . $row['mothers_nationality'] . '%')->first();
254
                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['mothers_identity_type'] . '%')->first();
255
                    $openemisMother = $this->uniqueUid::getUniqueAlphanumeric();
256
257
                    $identityType = $identityType !== null ? $identityType->id : null;
258
                    $nationalityId = $nationalityId !== null ? $nationalityId->id : null;
259
260
                    $mother = null;
261
262
                    if (!empty($row['mothers_identity_number'])) {
263
                        $mother = Security_user::where('identity_type_id', '=', $nationalityId)
264
                                        ->where('identity_number', '=', $row['mothers_identity_number'])->first();
265
                    }
266
267
                    if ($mother === null) {
268
                        $mother = Security_user::create([
269
                                    'username' => str_replace('-','',$openemisMother),
270
                                    'openemis_no' => $openemisMother,
271
                                    'first_name' => $row['mothers_full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
272
                                    'last_name' => genNameWithInitials($row['mothers_full_name']),
273
                                    'gender_id' => 2,
274
                                    'date_of_birth' => $row['mothers_date_of_birth_yyyy_mm_dd'],
275
                                    'address' => $row['mothers_address'],
276
                                    'address_area_id' => $AddressArea->id,
277
                                    'nationality_id' => $nationalityId,
278
                                    'identity_type_id' => $identityType,
279
                                    'identity_number' => $row['mothers_identity_number'],
280
                                    'is_guardian' => 1,
281
                                    'created_user_id' => $this->file['security_user_id']
282
                        ]);
283
284
                        $mother['guardian_relation_id'] = 2;
285
                        if (array_key_exists('mothers_phone', $row)) {
286
                            $mother['contact'] = $row['mothers_phone'];
287
                            User_contact::createOrUpdate($mother,$this->file['security_user_id']);
288
                        }   
289
                        Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
290
                    } else {
291
                        Security_user::where('id', '=', $mother->id)
292
                                ->update(['is_guardian' => 1]);
293
                        $mother['guardian_relation_id'] = 2;
294
                        if (array_key_exists('mothers_phone', $row)) {
295
                            $mother['contact'] = $row['mothers_phone'];
296
                            User_contact::createOrUpdate($mother,$this->file['security_user_id']);
297
                        }
298
                        Student_guardian::createStudentGuardian($student, $mother, $this->file['security_user_id']);
299
                    }
300
                }
301
302
303
                if (!empty($row['guardians_full_name']) && ($row['guardians_date_of_birth_yyyy_mm_dd'] !== null)) {
304
                    $genderId = $row['guardians_gender_mf'] == 'M' ? 1 : 2;
305
                    $AddressArea = Area_administrative::where('name', 'like', '%' . $row['guardians_address_area'] . '%')->first();
306
                    $nationalityId = Nationality::where('name', 'like', '%' . $row['guardians_nationality'] . '%')->first();
307
                    $identityType = Identity_type::where('national_code', 'like', '%' . $row['guardians_identity_type'] . '%')->first();
308
                    $openemisGuardian = $this->uniqueUid::getUniqueAlphanumeric();
309
310
                    $identityType = $identityType !== null ? $identityType->id : null;
311
                    $nationalityId = $nationalityId !== null ? $nationalityId->id : null;
312
313
                    $guardian = null;
314
315
                    if (!empty($row['guardians_identity_number'])) {
316
                        $guardian = Security_user::where('identity_type_id', '=', $nationalityId)
317
                                        ->where('identity_number', '=', $row['guardians_identity_number'])->first();
318
                    }
319
320
                    if ($guardian === null) {
321
                        $guardian = Security_user::create([
322
                                    'username' => str_replace('-','',$openemisGuardian),
323
                                    'openemis_no' => $openemisGuardian,
324
                                    'first_name' => $row['guardians_full_name'], // here we save full name in the column of first name. re reduce breaks of the system.
325
                                    'last_name' => genNameWithInitials($row['guardians_full_name']),
326
                                    'gender_id' => $genderId,
327
                                    'date_of_birth' => $row['guardians_date_of_birth_yyyy_mm_dd'],
328
                                    'address' => $row['guardians_address'],
329
                                    'address_area_id' => $AddressArea->id,
330
//                            'birthplace_area_id' => $BirthArea->id,
331
                                    'nationality_id' => $nationalityId,
332
                                    'identity_type_id' => $identityType,
333
                                    'identity_number' => $row['guardians_identity_number'],
334
                                    'is_guardian' => 1,
335
                                    'created_user_id' => $this->file['security_user_id']
336
                        ]);
337
338
                        $guardian['guardian_relation_id'] = 3;
339
                        if (array_key_exists('guardians_phone', $row)) {
340
                            $guardian['contact'] = $row['guardians_phone'];
341
                            User_contact::createOrUpdate($guardian,$this->file['security_user_id']);
342
                        }  
343
                        Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
344
                    } else {
345
                        Security_user::where('id', '=', $guardian->id)
346
                                ->update(['is_guardian' => 1]);
347
                        $guardian['guardian_relation_id'] = 3;
348
                        if (array_key_exists('guardians_phone', $row)) {
349
                            $guardian['contact'] = $row['guardians_phone'];
350
                            User_contact::createOrUpdate($guardian,$this->file['security_user_id']);
351
                        } 
352
                        Student_guardian::createStudentGuardian($student, $guardian, $this->file['security_user_id']);
353
                    }
354
                }
355
356
                $optionalSubjects =  Institution_class_subject::getStudentOptionalSubject($subjects, $student, $row, $institution);
357
358
                $allSubjects = array_merge_recursive($optionalSubjects, $mandatorySubject);
359
                // $stundetSubjects = $this->getStudentSubjects($student);
360
                // $allSubjects = array_merge_recursive($newSubjects, $stundetSubjects);
361
362
                if (!empty($allSubjects)) {
363
                    $allSubjects = unique_multidim_array($allSubjects, 'institution_subject_id');
364
                    $this->student = $student;
0 ignored issues
show
Bug Best Practice introduced by
The property student does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
365
                    $allSubjects = array_map(array($this,'setStudentSubjects'),$allSubjects);
366
                    // $allSubjects = array_unique($allSubjects,SORT_REGULAR);
367
                    $allSubjects = unique_multidim_array($allSubjects, 'education_subject_id');
368
                    array_walk($allSubjects,array($this,'insertSubject'));
369
                    array_walk($allSubjects, array($this, 'updateSubjectCount'));
370
                }
371
372
                unset($allSubjects);
373
374
                $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']);
375
376
                Institution_class::where('id', '=', $institutionClass->id)
377
                        ->update([
378
                            'total_male_students' => $totalStudents['total_male_students'],
379
                            'total_female_students' => $totalStudents['total_female_students']]);
380
            }
381
        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
382
            $error = \Illuminate\Validation\ValidationException::withMessages([]);
383
            $failures = $e->failures();
384
            throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures);
385
            Log::info('email-sent', [$e]);
0 ignored issues
show
Unused Code introduced by
Illuminate\Support\Facad...email-sent', array($e)) is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
386
        }
387
        unset($row);
388
    }
389
390
    public function getStudentSubjects($student) {
391
        return Institution_subject_student::where('student_id', '=', $student->student_id)
392
                        ->where('institution_class_id', '=', $student->institution_class_id)->get()->toArray();
393
    }
394
395
396
    public function rules(): array {
397
398
        return [
399
            '*.student_id' => 'required|exists:security_users,openemis_no|is_student_in_class:'.$this->file['institution_class_id'],
400
            '*.full_name' => 'nullable|regex:/^[\pL\s\-]+$/u|max:100',
401
            '*.gender_mf' => 'nullable|in:M,F',
402
            '*.date_of_birth_yyyy_mm_dd' => 'date|nullable',
403
            '*.address' => 'nullable',
404
            '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place',
405
            '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate',
406
            '*.nationality' => 'nullable',
407
            '*.identity_type' => 'required_with:identity_number',
408
//            '*.identity_number' => 'user_unique:identity_number',
409
            '*.academic_period' => 'required_with:*.admission_no|nullable|exists:academic_periods,name',
410
            '*.education_grade' => 'nullable|exists:education_grades,code',
411
            '*.option_*' => 'nullable|exists:education_subjects,name',
412
            '*.bmi_height' => 'required_with:*.bmi_weight|nullable|numeric|max:200|min:60',
413
            '*.bmi_weight' => 'required_with:*.bmi_height|nullable|numeric|max:200|min:10',
414
            '*.bmi_date_yyyy_mm_dd' => 'required_with:*.bmi_height|nullable|date',
415
            '*.bmi_academic_period' => 'required_with:*.bmi_weight|nullable|exists:academic_periods,name',
416
            '*.admission_no' => 'nullable|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/',
417
            '*.start_date_yyyy_mm_dd' => 'nullable|date',
418
            '*.special_need_type' => 'nullable',
419
            '*.special_need' => 'nullable|exists:special_need_difficulties,name|required_if:special_need_type,Differantly Able',
420
            '*.fathers_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u',
421
            '*.fathers_date_of_birth_yyyy_mm_dd' => 'nullable|required_with:*.fathers_full_name',
422
            '*.fathers_address' => 'required_with:*.fathers_full_name',
423
            '*.fathers_address_area' => 'required_with:*.fathers_full_name|nullable|exists:area_administratives,name',
424
            '*.fathers_nationality' => 'required_with:*.fathers_full_name',
425
            '*.fathers_identity_type' => 'required_with:*.fathers_identity_number',
426
            '*.fathers_identity_number' => 'nullable|required_with:*.fathers_identity_type|nic:fathers_identity_number',
427
            '*.mothers_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u',
428
            '*.mothers_date_of_birth_yyyy_mm_dd' => 'nullable|required_with:*.mothers_full_name',
429
            '*.mothers_address' => 'required_with:*.mothers_full_name',
430
            '*.mothers_address_area' => 'required_with:*.mothers_full_name|nullable|exists:area_administratives,name',
431
            '*.mothers_nationality' => "required_with:*.mothers_full_name",
432
            '*.mothers_identity_type' => "required_with:*.mothers_identity_number",
433
            '*.mothers_identity_number' => 'nullable|required_with:*.mothers_identity_type|nic:mothers_identity_number',
434
            '*.guardians_full_name' => 'nullable|regex:/^[\pL\s\-]+$/u',
435
            '*.guardians_gender_mf' => 'required_with:*.guardians_full_name',
436
            '*.guardians_date_of_birth_yyyy_mm_dd' => 'nullable|required_with:*.guardians_full_name',
437
            '*.guardians_address' => 'required_with:*.guardians_full_name',
438
            '*.guardians_address_area' => 'required_with:*.guardians_full_name|nullable|exists:area_administratives,name',
439
            '*.guardians_nationality' => 'required_with:*.guardians_full_name',
440
            '*.guardians_identity_type' => 'required_with:*.guardians_identity_number',
441
            '*.guardians_identity_number' => 'nullable|required_with:*.guardians_identity_type|nic:guardians_identity_number',
442
        ];
443
    }
444
445
}
446