xref: /webtrees/resources/views/modules/family-book-chart/children.phtml (revision 94db7d2d27c3ad6a04fceebbdcb98e28e97649b3)
1<?php
2
3use Fisharebest\Webtrees\Family;
4use Fisharebest\Webtrees\Individual;
5use Illuminate\Support\Collection;
6
7/**
8 * @var Collection<int,Individual> $children
9 * @var int                        $generations
10 */
11
12?>
13<div class="align-self-center">
14    <?php foreach ($children as $n => $child) : ?>
15        <?php $grandchildren = $child->spouseFamilies()->map(static function (Family $family): Collection {
16    return $family->children();
17        })->flatten() ?>
18        <div class="d-flex justify-content-end">
19            <?php if ($generations > 1 && $grandchildren->isNotEmpty()) : ?>
20                <?= view('modules/family-book-chart/children', ['children' => $grandchildren, 'generations' => $generations - 1]) ?>
21            <?php endif ?>
22            <div class="align-self-center">
23                <?= view('chart-box', ['individual' => $child]) ?>
24            </div>
25            <div class="wt-chart-horizontal-spacer">
26                <?php if ($children->count() === 1) : ?>
27                    <div class="wt-chart-horizontal-line"></div>
28                <?php elseif ($n === 0) : ?>
29                    <div class="wt-chart-horizontal-first-child"></div>
30                <?php elseif ($n + 1 === $children->count()) : ?>
31                    <div class="wt-chart-horizontal-last-child"></div>
32                <?php else : ?>
33                    <div class="wt-chart-horizontal-middle-child">
34                        <div class="wt-chart-horizontal-line"></div>
35                    </div>
36                <?php endif ?>
37            </div>
38        </div>
39    <?php endforeach ?>
40</div>
41<?php if ($children->count() > 0) : ?>
42    <div class="wt-chart-horizontal-spacer">
43        <div class="wt-chart-horizontal-line"></div>
44    </div>
45<?php endif ?>
46