xref: /webtrees/resources/views/modules/hourglass-chart/children.phtml (revision 12a0693f1b6760e019806135ae71270602315868)
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 {
16    return $family->children();
17        })->flatten() ?>
18        <div class="d-flex justify-content-end">
19            <?php if ($grandchildren->isNotEmpty()) : ?>
20                <?php if ($generations > 1) : ?>
21                    <?= view('modules/hourglass-chart/children', ['children' => $grandchildren, 'generations' => $generations - 1, 'spouses' => $spouses]) ?>
22                <?php else : ?>
23                    <div class="d-flex align-self-center">
24                        <div class="hourglass-arrow" data-xref="<?= route('module', ['module' => 'hourglass_chart', 'action' => 'Descendants', 'xref' => $child->xref(), 'tree' => $child->tree()->name(), 'spouses' => $spouses]) ?>">
25                            <?= view('icons/arrow-left') ?>
26                        </div>
27                    </div>
28                <?php endif ?>
29            <?php endif ?>
30            <div class="align-self-center">
31                <?php if ($spouses) : ?>
32                    <div>&nbsp;</div>
33                <?php endif ?>
34                <?= view('chart-box', ['individual' => $child]) ?>
35                <?php if ($spouses) : ?>
36                    <?php foreach ($child->spouseFamilies() as $spouse_family) : ?>
37                        <?= view('chart-box', ['individual' => $spouse_family->spouse($child)]) ?>
38                    <?php endforeach ?>
39                    <div>&nbsp;</div>
40                <?php endif ?>
41            </div>
42            <div class="wt-chart-horizontal-spacer">
43                <?php if ($children->count() === 1) : ?>
44                    <div class="wt-chart-horizontal-line"></div>
45                <?php elseif ($n === 0) : ?>
46                    <div class="wt-chart-horizontal-first-child"></div>
47                <?php elseif ($n + 1 === $children->count()) : ?>
48                    <div class="wt-chart-horizontal-last-child"></div>
49                <?php else : ?>
50                    <div class="wt-chart-horizontal-middle-child">
51                        <div class="wt-chart-horizontal-line"></div>
52                    </div>
53                <?php endif ?>
54            </div>
55        </div>
56    <?php endforeach ?>
57</div>
58
59<?php if ($children->count() > 0) : ?>
60    <div class="wt-chart-horizontal-spacer">
61        <div class="wt-chart-horizontal-line"></div>
62    </div>
63<?php endif ?>
64