forked from liberu-genealogy/genealogy-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge main into sweep/make_sure_dna_matching_in_dna_resources
- Loading branch information
Showing
4 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire; | ||
|
||
use Livewire\Component; | ||
use App\Models\Person; | ||
|
||
class HenryReport extends Component | ||
{ | ||
public $selectedPersonId; | ||
public $reportData = []; | ||
|
||
public function render() | ||
{ | ||
return view('livewire.henry-report', ['reportData' => $this->reportData]); | ||
} | ||
|
||
public function generateReport($personId) | ||
{ | ||
$this->selectedPersonId = $personId; | ||
$person = Person::find($personId); | ||
if ($person) { | ||
$this->reportData = []; | ||
$this->processHenryReportData($person); | ||
} | ||
} | ||
|
||
private function processHenryReportData($person) | ||
{ | ||
$this->reportData[$person->id] = [ | ||
'name' => $person->fullname(), | ||
'birth' => optional($person->birth())->date, | ||
'death' => optional($person->death())->date, | ||
]; | ||
|
||
$childNumber = 1; | ||
foreach ($person->child_in_family as $child) { | ||
$this->processHenryReportData($child, $childNumber); | ||
$childNumber++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div> | ||
<form wire:submit.prevent="generateReport(selectedPersonId)"> | ||
<div class="form-group"> | ||
<label for="personSelect">Select a Person:</label> | ||
<select id="personSelect" class="form-control" wire:model="selectedPersonId"> | ||
<option value="">--Choose--</option> | ||
@foreach(\App\Models\Person::all() as $person) | ||
<option value="{{ $person->id }}">{{ $person->name }}</option> | ||
@endforeach | ||
</select> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Generate Report</button> | ||
</form> | ||
|
||
<div wire:loading> | ||
Generating report... | ||
</div> | ||
|
||
@if(!empty($reportData)) | ||
<table class="table mt-4"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Birth Date</th> | ||
<th>Death Date</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($reportData as $data) | ||
<tr> | ||
<td>{{ $data['name'] }}</td> | ||
<td>{{ $data['birth'] }}</td> | ||
<td>{{ $data['death'] }}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
@endif | ||
</div> | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div> | ||
<!-- The content of the view goes here, following the structure above --> | ||
</div> | ||
@endsection |