| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace App\Models; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Lsf\UniqueUid\UniqueUid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use App\Models\Unique_user_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Illuminate\Database\Eloquent\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Illuminate\Support\Facades\Log; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class Security_user extends Model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     public const CREATED_AT = 'created'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     public const UPDATED_AT = 'modified'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * The database table used by the model. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     public $timestamps = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     protected $table = 'security_users'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected $appends = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         'special_need_name' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * Attributes that should be mass-assignable. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     protected $fillable = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'openemis_no', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         'first_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         'last_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         'address', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'address_area_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         'birthplace_area_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         'gender_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         'remember_token', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         'date_of_birth', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         'nationality_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         'identity_type_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         'identity_number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         'is_student', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         'modified_user_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         'modified', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         'created_user_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         'created', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         'username', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         'password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * The attributes excluded from the model's JSON form. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     protected $hidden = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         'password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         'modified_user_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         'middle_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         'third_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         'modified', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         'created_user_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         'created' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     public function getSpecialNeedNameAttribute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         return optional($this->special_needs())->special_need_difficulty_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * The attributes that should be casted to native types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     protected $casts = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function institutionStudents() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         return $this->hasOne(Institution_student::class, 'student_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     public function institutionStudentsClass() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         return $this->hasOne(Institution_student::class, 'student_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * The attributes that should be mutated to dates. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     protected $dates = ['date_of_birth', 'date_of_death', 'last_login', 'modified', 'created']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     public function rules() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             'identity_number' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                 'required', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                 'unique:security_users,identity_number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public function getAuthPassword() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         return $this->password; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     public function uploads() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         return $this->hasMany('App\Models\Upload'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function class() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         return $this->belongsTo('App\Models\Institution_class_student', 'id', 'student_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     public function special_needs() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         return $this->hasMany('App\Models\User_special_need', 'id', 'security_user_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     public function genUUID() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         $uuid = Uuid::generate(4); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         return str_split($uuid, '8')[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * First level search for students | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      * @param array $student | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     public function getMatches($student) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         ->where('gender_id',$student['gender'] + 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         ->where('institutions.code',$student['schoolid']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         ->where('date_of_birth',$student['b_date']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |             ->join('institution_students', 'security_users.id', 'institution_students.student_id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             ->join('institutions', 'institution_students.institution_id', 'institutions.id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             ->get()->toArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |      * First level search for students | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * @param array $student | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 160 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |     public function getStudentCount($student) | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |         return $this | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |         ->where('gender_id',$student['gender'] + 1) | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |         ->where('institutions.code',$student['schoolid']) | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |         ->where('date_of_birth',$student['b_date']) | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |             ->join('institution_students', 'security_users.id', 'institution_students.student_id') | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |             ->join('institutions', 'institution_students.institution_id', 'institutions.id') | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |             ->count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * insert student data from examination | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * @input array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     public function insertExaminationStudent($student) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $this->uniqueUserId = new Unique_user_id(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $this->uniqueUId = new UniqueUid(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $uniqueId = $this->uniqueUId::getUniqueAlphanumeric(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $studentData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             'username' => str_replace('-', '', $uniqueId), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             'openemis_no' => $uniqueId, // Openemis no is unique field, in case of the duplication it will failed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             'first_name' => $student['f_name'], // here we save full name in the column of first name. re reduce breaks of the system. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             'last_name' => genNameWithInitials($student['f_name']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             'gender_id' => $student['gender'] + 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             'date_of_birth' => $student['b_date'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             'address' => $student['pvt_address'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             'is_student' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             'updated_from' => 'doe', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             'created' => now(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             'created_user_id' => 1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             $id = $this->insertGetId($studentData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             $studentData['id'] = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             $this->uniqueUserId->updateOrInsertRecord($studentData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             return $studentData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         } catch (\Exception $th) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             Log::error($th->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             // in case of duplication of the Unique ID this will recursive. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             $this->insertExaminationStudent($student); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         return $studentData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * Update the existing student's data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * @param array $student | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @param array $sis_student | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |     public function updateExaminationStudent($student, $sis_student) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $this->uniqueUserId = new Unique_user_id(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $this->uniqueUId = new UniqueUid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         // regenerate unique id if it's not available | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'],9)) ?  $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $studentData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             'username' => str_replace('-', '', $uniqueId), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             'openemis_no' => $uniqueId, // Openemis no is unique field, in case of the duplication it will failed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             'first_name' => $student['f_name'], // here we save full name in the column of first name. re reduce breaks of the system. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             'last_name' => genNameWithInitials($student['f_name']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             'date_of_birth' => $student['b_date'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             'address' => $student['pvt_address'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             'updated_from' => 'doe', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             'modified' => now() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             self::where( 'id'  , $sis_student['student_id'])->update($studentData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             $studentData['id'] = $sis_student['student_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             $this->uniqueUserId->updateOrInsertRecord($studentData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             return $studentData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         } catch (\Exception $th) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             Log::error($th); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             // in case of duplication of the Unique ID this will recursive. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             $this->updateExaminationStudent($student, $sis_student); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 246 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 247 |  |  |  | 
            
                        
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.