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