I a trying to generate page serial with children but not working.
My code
Parent Blade
//index.blade.php
<?php $counter = 0; ?>
@if(isset($items) && count($items))
@foreach($items as $item)
<tr class="success">
<td>{{ ++$counter }}</td>
</tr>
@php
$rows = $item->children()->get();
@endphp
@if (count($rows) > 0)
@include('rows', ['rows' => $rows, 'counter' => $counter])
@endif
@endforeach
@endif
Child Blade
//rows.blade.php
@foreach($rows as $row)
@php
$titles = $row->getSuperTitle($row);
@endphp
<tr>
<td>{{ ++$counter }}</td>
</tr>
@php
$childRows = $row->children()->get();
@endphp
@if (count($childRows) > 0)
@include('rows', ['rows' => $childRows, 'counter' => $counter])
@endif
@endforeach
The code return the below view
But I am Looking for below
Do not pass $counter
to include. Check it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.