"Filters" table looks like following:
id | group | label | value
----+----------+-------------------+----------------
12 | deadline | 1 to 3 days | 1 AND 3
14 | price | Any | 0
15 | price | Less than 1000 | 0 AND 1000
16 | price | 1000 to 10000 | 1000 AND 10000
22 | location | Any | 0
23 | location | New York | newyork
24 | location | California | california
25 | location | Alabama | alabama
I need to show chunk of "label" under the "group".
My controller:
public function index(){
$filters = Filters::all();
return view('frontend.request', compact('filters'));
}
My view has:
<?php foreach ($filters as $filter) { ?>
<div class="panel panel-default">
<b>{{ $filter->group }}</b>
<div id="collapseOne1" class="panel-collapse collapse in">
<div class="panel-body">
<div class="checkbox">
<label><input type="checkbox" name="{{ $filter->group }}" value="{{ $filter->any }}">{{ $filter->label }}</label>
</div>
</div>
</div>
</div>
<?php } ?>
I want to show all labels under the group within one box and so on. The above codes create different boxes for each label which is not right.
I believe, its got to be nested loop but I'm having difficult writing it on Laravel. Any idea how it should be?
Note: This thread gives partial answer but we don't know chunk size in my case: Laravel 5.1 - Nested Loop - Blade Templating