📜  laravel 父子同表 - PHP 代码示例

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

代码示例1
public function parent()
    {
        return $this->belongsTo('App\CourseModule','parent_id')->where('parent_id',0);
    }

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