📜  雄辩的自我外键 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:43.140000             🧑  作者: Mango

代码示例1
class User extends Eloquent {

    protected $table = 'users';
    public $timestamps = false;

    public function parent()
    {
        return $this->belongsTo('User', 'parent_id');
    }

    public function children()
    {
        return $this->hasMany('User', 'parent_id');
    }

}