laravel parent child same table

Solutions on MaxInterview for laravel parent child same table by the best coders in the world

showing results for - "laravel parent child same table"
María Paula
19 Feb 2017
1    public function parent()
2    {
3        return $this->belongsTo('App\CourseModule','parent_id')->where('parent_id',0);
4    }
5
6    public function children()
7    {
8        return $this->hasMany('App\CourseModule','parent_id');
9    }
10