|
|
|
@ -128,7 +128,7 @@ class User extends Authenticatable |
|
|
|
|
|
|
|
public function wifes() |
|
|
|
{ |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'husband_id', 'wife_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps(); |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'husband_id', 'wife_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps()->orderBy('marriage_date'); |
|
|
|
} |
|
|
|
|
|
|
|
public function addWife(User $wife, $marriageDate = null) |
|
|
|
@ -146,7 +146,7 @@ class User extends Authenticatable |
|
|
|
|
|
|
|
public function husbands() |
|
|
|
{ |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'wife_id', 'husband_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps(); |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'wife_id', 'husband_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps()->orderBy('marriage_date'); |
|
|
|
} |
|
|
|
|
|
|
|
public function addHusband(User $husband, $marriageDate = null) |
|
|
|
@ -170,19 +170,19 @@ class User extends Authenticatable |
|
|
|
public function couples() |
|
|
|
{ |
|
|
|
if ($this->gender_id == 1) { |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'husband_id', 'wife_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps(); |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'husband_id', 'wife_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps()->orderBy('marriage_date'); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->belongsToMany(User::class, 'couples', 'wife_id', 'husband_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps(); |
|
|
|
return $this->belongsToMany(User::class, 'couples', 'wife_id', 'husband_id')->using('App\CouplePivot')->withPivot(['id'])->withTimestamps()->orderBy('marriage_date'); |
|
|
|
} |
|
|
|
|
|
|
|
public function marriages() |
|
|
|
{ |
|
|
|
if ($this->gender_id == 1) { |
|
|
|
return $this->hasMany(Couple::class, 'husband_id'); |
|
|
|
return $this->hasMany(Couple::class, 'husband_id')->orderBy('marriage_date'); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->hasMany(Couple::class, 'wife_id'); |
|
|
|
return $this->hasMany(Couple::class, 'wife_id')->orderBy('marriage_date'); |
|
|
|
} |
|
|
|
|
|
|
|
public function siblings() |
|
|
|
|