atayahmet / laravel-nestable

Laravel 5 nested category/menu generator
MIT License
214 stars 52 forks source link

Category by Id #48

Closed mifas closed 6 years ago

mifas commented 6 years ago

Example category table

id parent_id name slug
1 0 Car car
2 1 BMW bmw
3 1 Benz benz
4 0 Truck truck

Is there any way to get Car's children only?

Current output. Truck category also return

{  
   "id":1,
   "name":"Car",
   "slug":"car",
   "child":[  
      {  
         "id":2,
         "name":"BMW",
         "slug":"bmw"
      },
      {  
         "id":3,
         "name":"Benz",
         "slug":"benz"
      }
   ]
},
{  
   "id":1,
   "name":"Truck",
   "slug":"truck"
}
ultrono commented 6 years ago

As per the documentation, see https://github.com/atayahmet/laravel-nestable#parent

mifas commented 6 years ago

That's not correct. Because I want ONLY Car's children. If I use ->parent(0) then Truck records will also return

atayahmet commented 6 years ago

Hi @mifas

There is no other way for now. You can fork it and send PR.

mifas commented 6 years ago

Thank you @atayahmet