So you want to get subcategories twice? Or just two collections. 1 with all subcategories and 1 with all categories (based on the first collection) ? How is the relationship? Belongs to I assume? And can you show your current code for getting the data?
public function parent()
{
return $this->belongsTo(Category::class, 'parent_id', 'id');
}
public function children()
{
return $this->hasMany(Category::class, 'parent_id');
}
@ga46 Not really. Can you show some code? All the subcategories are on the same level ? And you want to get every single parent all the way to the top, for each subcategory?