atayahmet / laravel-nestable

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

Multiple dropdowns using 'nestable($data)' #46

Closed palo closed 6 years ago

palo commented 6 years ago

I'm trying to render multiple dropdowns from level 0 categories, like so:

$categories = Category::nested()->get();

@foreach ( $categories as $category )
{!! nestable($category)->renderAsDropdown() !!}
@endforeach

But getting this error: "Illegal string offset 'parent_id'"..

If i pass it like this:

@foreach ( $categories as $category )
{!! nestable($category['child'])->renderAsDropdown() !!}
@endforeach

It renders empty dropdowns

Can you please explain how to achieve this?

atayahmet commented 6 years ago

Hi @palo

You can do it like this:

@foreach ( $categories as $category )
{!! nestable([$category])->renderAsDropdown() !!}
@endforeach
palo commented 6 years ago

Thank you