|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace FamilyTree365\LaravelGedcom\Utils\Exporter\Indi; |
|
4
|
|
|
|
|
5
|
|
|
use FamilyTree365\LaravelGedcom\Models\PersonName; |
|
6
|
|
|
|
|
7
|
|
|
class Name |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* \Gedcom\Record\Indi\Asso $asso |
|
11
|
|
|
* String $group |
|
12
|
|
|
* Integer $group_id. |
|
13
|
|
|
*/ |
|
14
|
|
|
public static function read($conn, \Gedcom\Record\Indi\Name $item, $group = '', $group_id = 0) |
|
15
|
|
|
{ |
|
16
|
|
|
$name = $item->getName(); |
|
17
|
|
|
$type = $item->getType(); |
|
18
|
|
|
$npfx = $item->getNpfx(); |
|
19
|
|
|
$givn = $item->getGivn(); |
|
20
|
|
|
$nick = $item->getNick(); |
|
21
|
|
|
$spfx = $item->getSpfx(); |
|
22
|
|
|
$surn = $item->getSurn(); |
|
23
|
|
|
$nsfx = $item->getNsfx(); |
|
24
|
|
|
|
|
25
|
|
|
// store asso |
|
26
|
|
|
$key = [ |
|
27
|
|
|
'group'=> $group, |
|
28
|
|
|
'gid' => $group_id, |
|
29
|
|
|
'type' => $type, |
|
30
|
|
|
'name' => $name, |
|
31
|
|
|
'npfx' => $npfx, |
|
32
|
|
|
'givn' => $givn, |
|
33
|
|
|
'nick' => $nick, |
|
34
|
|
|
'spfx' => $spfx, |
|
35
|
|
|
'surn' => $surn, |
|
36
|
|
|
'nsfx' => $nsfx, |
|
37
|
|
|
]; |
|
38
|
|
|
$data = [ |
|
39
|
|
|
'group'=> $group, |
|
40
|
|
|
'gid' => $group_id, |
|
41
|
|
|
'type' => $type, |
|
42
|
|
|
'name' => $name, |
|
43
|
|
|
'npfx' => $npfx, |
|
44
|
|
|
'givn' => $givn, |
|
45
|
|
|
'nick' => $nick, |
|
46
|
|
|
'spfx' => $spfx, |
|
47
|
|
|
'surn' => $surn, |
|
48
|
|
|
'nsfx' => $nsfx, |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
$record = PersonName::on($conn)->updateOrCreate($key, $data); |
|
52
|
|
|
|
|
53
|
|
|
$_group = 'indi_name'; |
|
54
|
|
|
$_gid = $record->id; |
|
55
|
|
|
// store Note |
|
56
|
|
|
$note = $item->getNote(); |
|
57
|
|
|
if ($note && count($note) > 0) { |
|
|
|
|
|
|
58
|
|
|
foreach ($note as $_item) { |
|
59
|
|
|
if ($_item) { |
|
60
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $_item, $_group, $_gid); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
// store sourref |
|
66
|
|
|
$sour = $item->getSour(); |
|
67
|
|
|
if ($sour && count($sour) > 0) { |
|
68
|
|
|
foreach ($sour as $_item) { |
|
69
|
|
|
if ($_item) { |
|
70
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $_item, $_group, $_gid); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
// store fone |
|
76
|
|
|
$fone = $item->getFone(); |
|
77
|
|
|
if ($fone != null) { |
|
78
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Name\Fone::read($conn, $fone, $_group, $_gid); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
// store romn |
|
82
|
|
|
$romn = $item->getRomn(); |
|
83
|
|
|
if ($romn != null) { |
|
84
|
|
|
\FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Name\Romn::read($conn, $romn, $_group, $_gid); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|