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