|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace FamilyTree365\LaravelGedcom\Utils\Importer\Sour; |
|
4
|
|
|
|
|
5
|
|
|
use FamilyTree365\LaravelGedcom\Models\SourceData; |
|
6
|
|
|
use FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef; |
|
7
|
|
|
use FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Data\Even; |
|
8
|
|
|
|
|
9
|
|
|
class Data |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Gedcom\Record\Sour\Data $data |
|
13
|
|
|
* String $group |
|
14
|
|
|
* Integer $group_id. |
|
15
|
|
|
*/ |
|
16
|
|
|
public static function read($conn, \Gedcom\Record\Sour\Data $data, $group = '', $group_id = 0) |
|
17
|
|
|
{ |
|
18
|
|
|
$date = $data->getDate(); |
|
19
|
|
|
$agnc = $data->getAgnc(); |
|
20
|
|
|
$text = $data->getText(); |
|
21
|
|
|
|
|
22
|
|
|
// store Data of sources |
|
23
|
|
|
$key = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'text'=>$text, 'agnc'=>$agnc]; |
|
24
|
|
|
$_data = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'text'=>$text, 'agnc'=>$agnc]; |
|
25
|
|
|
$record = SourceData::on($conn)->updateOrCreate($key, $_data); |
|
26
|
|
|
|
|
27
|
|
|
$_group = 'sourcedata'; |
|
28
|
|
|
$_gid = $record->id; |
|
29
|
|
|
// \Gedcom\Record\Sour\Data\Even array |
|
30
|
|
|
$even = $data->getEven(); |
|
31
|
|
|
if ($even && count($even) > 0) { |
|
|
|
|
|
|
32
|
|
|
foreach ($even as $item) { |
|
33
|
|
|
Even::read($conn, $item, $_group, $_gid); |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
// \Gedcom\Record\NoteRef array |
|
37
|
|
|
$note = $data->getNote(); |
|
38
|
|
|
if ($note && count($note) > 0) { |
|
39
|
|
|
foreach ($note as $item) { |
|
40
|
|
|
NoteRef::read($conn, $item, $_group, $_gid); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|