You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
661 B
36 lines
661 B
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Couple extends Model
|
|
{
|
|
public function husband()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function wife()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function childs()
|
|
{
|
|
return $this->hasMany(User::class, 'parent_id');
|
|
}
|
|
|
|
public function addChild(User $user)
|
|
{
|
|
$user->parent_id = $this->id;
|
|
$user->father_id = $this->husband_id;
|
|
$user->mother_id = $this->wife_id;
|
|
$user->save();
|
|
}
|
|
|
|
public function manager()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|