xref: /webtrees/resources/views/modules/hourglass-chart/children.phtml (revision dc270d8cc5085ed29f3f419c99734ddd0960c624)
1cb0eb4a9SGreg Roach<?php
2cb0eb4a9SGreg Roach
3cb0eb4a9SGreg Roachuse Fisharebest\Webtrees\Family;
4*dc270d8cSGreg Roachuse Fisharebest\Webtrees\Individual;
5cb0eb4a9SGreg Roachuse Illuminate\Support\Collection;
6cb0eb4a9SGreg Roach
7cb0eb4a9SGreg Roach/**
8*dc270d8cSGreg Roach * @var Collection<Individual> $children
9cb0eb4a9SGreg Roach * @var int                    $generations
1071378461SGreg Roach * @var bool                   $spouses
11cb0eb4a9SGreg Roach */
12cb0eb4a9SGreg Roach
13cb0eb4a9SGreg Roach?>
14cb0eb4a9SGreg Roach<div class="align-self-center">
15cb0eb4a9SGreg Roach    <?php foreach ($children as $n => $child) : ?>
16d70512abSGreg Roach        <?php $grandchildren = $child->spouseFamilies()->map(static function (Family $family): Collection {
17d70512abSGreg Roach    return $family->children();
18d70512abSGreg Roach        })->flatten() ?>
19cb0eb4a9SGreg Roach        <div class="d-flex justify-content-end">
20cb0eb4a9SGreg Roach            <?php if ($grandchildren->isNotEmpty()) : ?>
21cb0eb4a9SGreg Roach                <?php if ($generations > 1) : ?>
2271378461SGreg Roach                    <?= view('modules/hourglass-chart/children', ['children' => $grandchildren, 'generations' => $generations - 1, 'spouses' => $spouses]) ?>
23cb0eb4a9SGreg Roach                <?php else : ?>
24cb0eb4a9SGreg Roach                    <div class="d-flex align-self-center">
25d72b284aSGreg Roach                        <div class="hourglass-arrow" data-xref="<?= route('module', ['module' => 'hourglass_chart', 'action' => 'Descendants', 'xref' => $child->xref(), 'tree' => $child->tree()->name(), 'spouses' => $spouses]) ?>">
26cb0eb4a9SGreg Roach                            <?= view('icons/arrow-left') ?>
27cb0eb4a9SGreg Roach                        </div>
28cb0eb4a9SGreg Roach                    </div>
29cb0eb4a9SGreg Roach                <?php endif ?>
30cb0eb4a9SGreg Roach            <?php endif ?>
31cb0eb4a9SGreg Roach            <div class="align-self-center">
3271378461SGreg Roach                <?php if ($spouses) : ?>
33cb0eb4a9SGreg Roach                    <div>&nbsp;</div>
34cb0eb4a9SGreg Roach                <?php endif ?>
35cb0eb4a9SGreg Roach                <?= view('chart-box', ['individual' => $child]) ?>
3671378461SGreg Roach                <?php if ($spouses) : ?>
37cb0eb4a9SGreg Roach                    <?php foreach ($child->spouseFamilies() as $spouse_family) : ?>
38cb0eb4a9SGreg Roach                        <?= view('chart-box', ['individual' => $spouse_family->spouse($child)]) ?>
39cb0eb4a9SGreg Roach                    <?php endforeach ?>
40cb0eb4a9SGreg Roach                    <div>&nbsp;</div>
41b332fbfeSGreg Roach                <?php endif ?>
42cb0eb4a9SGreg Roach            </div>
43cb0eb4a9SGreg Roach            <div class="wt-chart-horizontal-spacer">
44cb0eb4a9SGreg Roach                <?php if ($children->count() === 1) : ?>
45cb0eb4a9SGreg Roach                    <div class="wt-chart-horizontal-line"></div>
46cb0eb4a9SGreg Roach                <?php elseif ($n === 0) : ?>
47cb0eb4a9SGreg Roach                    <div class="wt-chart-horizontal-first-child"></div>
48cb0eb4a9SGreg Roach                <?php elseif ($n + 1 === $children->count()) : ?>
49cb0eb4a9SGreg Roach                    <div class="wt-chart-horizontal-last-child"></div>
50cb0eb4a9SGreg Roach                <?php else : ?>
51cb0eb4a9SGreg Roach                    <div class="wt-chart-horizontal-middle-child">
52cb0eb4a9SGreg Roach                        <div class="wt-chart-horizontal-line"></div>
53cb0eb4a9SGreg Roach                    </div>
54cb0eb4a9SGreg Roach                <?php endif ?>
55cb0eb4a9SGreg Roach            </div>
56cb0eb4a9SGreg Roach        </div>
57cb0eb4a9SGreg Roach    <?php endforeach ?>
58cb0eb4a9SGreg Roach</div>
59cb0eb4a9SGreg Roach
60cb0eb4a9SGreg Roach<?php if ($children->count() > 0) : ?>
61cb0eb4a9SGreg Roach    <div class="wt-chart-horizontal-spacer">
62cb0eb4a9SGreg Roach        <div class="wt-chart-horizontal-line"></div>
63cb0eb4a9SGreg Roach    </div>
64cb0eb4a9SGreg Roach<?php endif ?>
65