arrilot / laravel-widgets

Widgets for Laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add getter of $widgets to WidgetGroup

nejtr0n opened this issue · comments

Hello.
Sometimes we need to have extra logic with widget groups.
For example, make tabs fo them.

                    <ul class="nav nav-tabs" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" data-toggle="tab" href="{{ $widget[1] }}" role="tab" aria-controls="home"> {{ $widget["name"] }}</a>
                        </li>
                    </ul>
<div class="tab-content">
{{ Widget::group('group')->display() }}
</div>

So we need to loop over widgets in group. It would be great to have getter or use Macroable trait on Widget group.

The idea to make widgets in group iteratable is cool, but it's not easy due to internal widget group implementation widgets in a group are instantiated and sorted only in display() method.
This implementation can probably be changed without big BC breaks though

I understand. Thank you for reply.