✅ How to group nested departments?
First of all I wanna show structure of departments:
FIRST OFFICE
| first room
| second room
| third room ( nested of second room )
SECOND OFFICE
| first room
| second room
| third room ( nested of second room )
okey, each office and each room has id, title and parent_id
for example, third_room will have parent_id == second room.id
if
so I have following code:
it will return all departments with id, parent_id but without any grouping and I don't understand how to group
I have
So I need the same but with
FIRST OFFICE
| first room
| second room
| third room ( nested of second room )
SECOND OFFICE
| first room
| second room
| third room ( nested of second room )
okey, each office and each room has id, title and parent_id
for example, third_room will have parent_id == second room.id
if
parent_id == null, this is root!so I have following code:
it will return all departments with id, parent_id but without any grouping and I don't understand how to group
I have
GetByParentId function so I can write this:So I need the same but with
GetByParentsIds function