jeudi 2 juin 2016

Showing Nested Data in Laravel Blade

I have a nested data like this which is passed to blade-

enter image description here

I want to display it's data in blade view.

So what I have done is-

<ul class="dropdown-menu h-ctr h-ctr2 col-md-12 col-sm-12">
    @foreach ($categories as $category)
        <li class="no-border">
            <label class="pull-left">
                <input type="checkbox" value="" checked>
                <strong>  (21)</strong>
            </label>
            <ul>
                @foreach($category->sub_category as $sub_cat)
                    <li>
                        <label class="pull-left">
                            <input type="checkbox" checked value="1">  (7)
                        </label>
                    </li>
                @endforeach
            </ul>

        </li>
    @endforeach
</ul>

And I am getting error for nested loop's part-

foreach($category->sub_category as $sub_cat)
    <li>
        <label class="pull-left">
            <input type="checkbox" checked value="1">  (7)
        </label>
    </li>
@endforeach

The error is like this-

enter image description here

Can anyone please help?

Thanks in advance for helping.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1r4x7Uz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire