i have two tables abc and def. i have models of these two tables named respectively Abc and Def. i Abc Model i declare these two functions.
public function child()
{
return $this->hasMany('Abc', 'parent');
}
// recursive, loads all descendants
public function children()
{
return $this->child()->with('children')->orderBy('sort_order');
}
// parent
public function parent()
{
return $this->belongsTo('Abc','parent');
}
// all ascendants
public function parentRecursive()
{
return $this->parent()->with('parentRecursive');
}
in controllers i called these functions by
$abc = Abc::with('children')->whereNull('parent')->get();
i have implemnted n level hierarchy JSON from table through parent child relation.i have common column name in both tables. through these method i get the title column of abc table.but i want to fetch title column of def table.how we can do this??
Thanks HARSH SHAH
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community