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