Group by subcollection (belongTo relationship)

Posted 1 month ago by aristain7

Hey

i have this in my controller

      $all =  $warehouse->with('category' )->where('WarehouseGroupID','=',$GroupID)->get();

and i get the following resaults

0: {WarehouseID: 1, WarehouseName: "TEST", WarehouseGroupID: -1, WarehouseCode: "244",…}
WarehouseAddress: null
WarehouseCategoryID: 13
WarehouseCity: null
WarehouseCode: "244"
WarehouseCountryID: null
WarehouseDescription: null
WarehouseGroupID: -1
WarehouseID: 1
WarehouseName: "TEST"
WarehouseRegionID: null
WarehouseStatus: 1
WarehouseUnitID: null
WarehouseUserID: null
WarehouseZipCode: null
category: {CategoryID: 13, CategoryCode: "24", CategoryName: "42424", CategoryUnitID: null, CategoryGroupID: -1,…}
CategoryCode: "24"
CategoryGroupID: -1
CategoryID: 13
CategoryName: "42424"
CategoryParentID: 11
CategoryUnitID: null
created_at: "2019-05-26 07:30:54"
updated_at: "2019-05-26 07:30:54"
created_at: "2019-04-08 17:47:34"
updated_at: "2019-04-08 17:47:34"

i want to group results by category subcollection any idea?

Please sign in or create an account to participate in this conversation.