1 | <?php |
||||||
2 | |||||||
3 | namespace FamilyTree365\LaravelGedcom\Utils; |
||||||
4 | |||||||
5 | use FamilyTree365\LaravelGedcom\Models\Family; |
||||||
6 | use FamilyTree365\LaravelGedcom\Models\Person; |
||||||
7 | |||||||
8 | class FamilyData |
||||||
9 | { |
||||||
10 | /** |
||||||
11 | * Array of persons ID |
||||||
12 | * key - old GEDCOM ID |
||||||
13 | * value - new cyrus_authenticate(connection) sincrement ID. |
||||||
14 | * |
||||||
15 | * @var string |
||||||
16 | */ |
||||||
17 | protected $persons_id = []; |
||||||
18 | protected $subm_ids = []; |
||||||
19 | protected $sour_ids = []; |
||||||
20 | protected $obje_ids = []; |
||||||
21 | protected $note_ids = []; |
||||||
22 | protected $repo_ids = []; |
||||||
23 | protected $conn = ''; |
||||||
24 | |||||||
25 | public static function getFamily($conn, $families, $obje_ids = [], $sour_ids = [], $persons_id = [], $note_ids = [], $repo_ids = [], $parentData = []) |
||||||
0 ignored issues
–
show
The parameter
$repo_ids is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() The parameter
$note_ids is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
26 | { |
||||||
27 | $familyData = []; |
||||||
0 ignored issues
–
show
|
|||||||
28 | $persons_id = []; |
||||||
29 | |||||||
30 | try { |
||||||
31 | foreach ($families as $family) { |
||||||
32 | $g_id = $family->getId(); |
||||||
0 ignored issues
–
show
|
|||||||
33 | $resn = $family->getResn(); |
||||||
0 ignored issues
–
show
|
|||||||
34 | $husb = $family->getHusb(); |
||||||
35 | $wife = $family->getWife(); |
||||||
36 | |||||||
37 | // string |
||||||
38 | $nchi = $family->getNchi(); |
||||||
39 | $rin = $family->getRin(); |
||||||
40 | |||||||
41 | // array |
||||||
42 | $subm = $family->getSubm(); |
||||||
0 ignored issues
–
show
|
|||||||
43 | $_slgs = $family->getSlgs(); |
||||||
0 ignored issues
–
show
|
|||||||
44 | |||||||
45 | $description = null; |
||||||
46 | $type_id = 0; |
||||||
47 | |||||||
48 | $children = $family->getChil(); |
||||||
0 ignored issues
–
show
|
|||||||
49 | $events = $family->getAllEven(); |
||||||
0 ignored issues
–
show
|
|||||||
50 | $_note = $family->getNote(); |
||||||
0 ignored issues
–
show
|
|||||||
51 | $_obje = $family->getObje(); |
||||||
0 ignored issues
–
show
|
|||||||
52 | $_sour = $family->getSour(); |
||||||
0 ignored issues
–
show
|
|||||||
53 | $_refn = $family->getRefn(); |
||||||
0 ignored issues
–
show
|
|||||||
54 | |||||||
55 | $chan = $family->getChan(); |
||||||
0 ignored issues
–
show
|
|||||||
56 | |||||||
57 | $husband_key = $parentData ? array_search($husb, array_column($parentData, 'gid')) : null; |
||||||
58 | $husband_uid = $parentData[$husband_key]['uid'] ?? null; |
||||||
59 | if (Person::where('uid', $husband_uid)->first() != null) { |
||||||
60 | $husband_id = Person::where('uid', $husband_uid)->first()->id; |
||||||
61 | } else { |
||||||
62 | $husband_id = null; |
||||||
63 | } |
||||||
64 | |||||||
65 | $wife_key = $parentData ? array_search($wife, array_column($parentData, 'gid')) : null; |
||||||
66 | $wife_uid = $parentData[$wife_key]['uid'] ?? null; |
||||||
67 | if (Person::where('uid', $wife_uid)->first() != null) { |
||||||
68 | $wife_id = Person::where('uid', $wife_uid)->first()->id; |
||||||
69 | } else { |
||||||
70 | $wife_id = null; |
||||||
71 | } |
||||||
72 | |||||||
73 | $persons_id[$husb] = $husband_id; |
||||||
74 | $persons_id[$wife] = $wife_id; |
||||||
75 | |||||||
76 | $value = [ |
||||||
77 | 'husband_id' => $husband_id, |
||||||
78 | 'wife_id' => $wife_id, |
||||||
79 | 'description' => $description, |
||||||
80 | 'type_id' => $type_id, |
||||||
81 | 'nchi' => $nchi, |
||||||
82 | 'rin' => $rin, |
||||||
83 | ]; |
||||||
84 | |||||||
85 | Family::on($conn)->updateOrCreate($value, $value); |
||||||
86 | } |
||||||
87 | otherFamRecord::insertFamilyData($conn, $persons_id, $families, $obje_ids, $sour_ids); |
||||||
88 | } catch (\Exception $e) { |
||||||
89 | $error = $e->getMessage(); |
||||||
90 | |||||||
91 | return \Log::error($error); |
||||||
92 | } |
||||||
93 | } |
||||||
94 | } |
||||||
95 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.