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