I am using this query to get the children of each category
$this['children'] = Cat::first()->children;
But it only gets the subcategories of of the first category and the same subcategories appear for all other categories. Any ideas on how t fix this?
Model relation
public function children(){
return $this->hasMany(static::class,'parent_id','id');
Table structure
category table
id
cat_title
parent_id
nest_right
nest_left
nest_depth
slug
parent_id = 0(category)
parent_id > 0(subcategory)
with
,Cat::with('children')->get();
– Farrukh Ayyaz