/home/techb158/ileadtechnology.com/SSM/app/Models/student
Edit: /home/techb158/ileadtechnology.com/SSM/app/Models/student/StudentParent.php (5559B)
'array', 'first_guardian_date_of_birth' => 'date', 'second_guardian_date_of_birth' => 'date'];
protected $primaryKey = 'id';
protected $table = 'student_parents';
protected static $logName = 'student_parent';
protected static $logFillable = true;
protected static $logOnlyDirty = true;
protected static $ignoreChangedAttributes = ['updated_at'];
protected $appends = ['father_name', 'mother_name', 'spouse_name'];
public function students()
{
return $this->hasMany('App\Models\Student\Student');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function getOption(string $option)
{
return array_get($this->options, $option);
}
public function getFatherNameAttribute()
{
if ($this->first_guardian_relation == 'father') {
return $this->first_guardian_name;
} else if ($this->second_guardian_relation == 'father') {
return $this->second_guardian_name;
} else if ($this->third_guardian_relation == 'father') {
return $this->third_guardian_name;
} else {
return;
}
}
public function getMotherNameAttribute()
{
if ($this->first_guardian_relation == 'mother') {
return $this->first_guardian_name;
} else if ($this->second_guardian_relation == 'mother') {
return $this->second_guardian_name;
} else if ($this->third_guardian_relation == 'mother') {
return $this->third_guardian_name;
} else {
return;
}
}
public function getSpouseNameAttribute()
{
if ($this->first_guardian_relation == 'spouse') {
return $this->first_guardian_name;
} else if ($this->second_guardian_relation == 'spouse') {
return $this->second_guardian_name;
} else if ($this->third_guardian_relation == 'spouse') {
return $this->third_guardian_name;
} else {
return;
}
}
public function scopeFilterById($q, $id)
{
if (! $id) {
return $q;
}
return $q->where('id', '=', $id);
}
public function scopeFilterByFirstGuardianName($q, $first_guardian_name, $strict = 0)
{
if (! $first_guardian_name) {
return $q;
}
return ($strict) ? $q->where('first_guardian_name', '=', $first_guardian_name) : $q->where('first_guardian_name', 'like', '%'.$first_guardian_name.'%');
}
public function scopeFilterBySecondGuardianName($q, $second_guardian_name, $strict = 0)
{
if (! $second_guardian_name) {
return $q;
}
return ($strict) ? $q->where('second_guardian_name', '=', $second_guardian_name) : $q->where('second_guardian_name', 'like', '%'.$second_guardian_name.'%');
}
public function scopeFilterByFirstGuardianContactNumber1($q, $first_guardian_contact_number_1)
{
if (! $first_guardian_contact_number_1) {
return $q;
}
return $q->where('first_guardian_contact_number_1', '=', $first_guardian_contact_number_1);
}
}