xref: /webtrees/resources/views/modules/family-book-chart/chart.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
8use Illuminate\Support\Collection;
9
10/**
11 * @var int        $book_size
12 * @var int        $generations
13 * @var Individual $individual
14 * @var bool       $spouses
15 */
16
17$children = $individual->spouseFamilies()->map(static function (Family $family): Collection {
18    return $family->children();
19})->flatten();
20
21?>
22
23<h3><?= I18N::translate('Family of %s', $individual->fullName()) ?></h3>
24
25<div class="d-flex wt-chart-family-book">
26    <?= view('modules/family-book-chart/children', ['children' => $children, 'generations' => $book_size - 1]) ?>
27    <div class="align-self-center">
28        <?= view('chart-box', ['individual' => $individual]) ?>
29        <?php if ($spouses) : ?>
30            <?php foreach ($individual->spouseFamilies() as $family) : ?>
31                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
32            <?php endforeach ?>
33        <?php endif ?>
34    </div>
35    <div class="wt-chart-horizontal-spacer">
36        <div class="wt-chart-horizontal-line"></div>
37    </div>
38    <?= view('modules/family-book-chart/parents', ['generations' => $book_size - 1, 'family' => $individual->childFamilies()->first()]) ?>
39</div>
40
41<?php if ($generations > 1) : ?>
42    <?php foreach ($children as $child) : ?>
43        <hr class="wt-family-separator">
44        <?= view('modules/family-book-chart/chart', ['individual' => $child, 'generations' => $generations - 1, 'book_size' => $book_size, 'spouses' => $spouses]) ?>
45    <?php endforeach ?>
46<?php endif ?>
47