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