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