atayahmet / laravel-nestable

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

Need help with passing an additional where condition. #65

Closed malaymehta closed 5 years ago

malaymehta commented 5 years ago

Hello, Thank you for this awesome package.

I have used this and it works well. But I have a different situation. I am using for storing the books and it's chapters, so there is one additional field "book_id", for which I need the nestable set. But I always get all the records without the child key.

Can you please let me know if this package does support this feature or there is no known solution to this. If I need to use some other custom solution for this.

Thanks in advance.

atayahmet commented 5 years ago

Hi @malaymehta

Sorry for my late answer.

This package is only support nested structures. Does not support sql query with child elements. You can get items by native sql query then you can pass the results to nestable() helper function.

Example:

$books = Book::where('book_id', 2)->get();

nestable($books)->renderAsJson();