Friday, March 3, 2017

How to list name of subcategory by category_id?

I am trying to list subcategory name by category_id where category_id should be grouped and show all subcategory name of that grouped id. Please see the attached figure shown in below:- This picture for database

This is what I get from my query

In my web page category name shown repeatedly but I want category should be display one and subcategory name should be display. For example:-

category name   || subcategory name||
Data Management || pa , roji       ||
Executive       || lov, true       ||

My simple using relationship query is:-

TeamSubCategory::with('category')->orderBy('weight')->get();



via Pawan Dongol

Advertisement