public static function addSpouse($spouse, $individualId, $spouseId) { $newSpouse = new Spouse(); $newSpouse->personId = $individualId; $newSpouse->spouse = $spouseId; $newSpouse->day = $spouse->marriageDate->day; $newSpouse->month = $spouse->marriageDate->month; $newSpouse->year = $spouse->marriageDate->year; $newSpouse->yearM = $spouse->marriageDate->yearM; $spouseId = $newSpouse->save(); if ($spouseId) { $newSpouse->id = $spouseId; $marriagePlace = new Place(); if ($spouse->marriagePlace && isset($spouse->marriagePlace->town)) { $marriagePlace->town = $spouse->marriagePlace->town; } if ($spouse->marriagePlace && isset($spouse->marriagePlace->county)) { $marriagePlace->county = $spouse->marriagePlace->county; } if ($spouse->marriagePlace && isset($spouse->marriagePlace->state)) { $marriagePlace->state = $spouse->marriagePlace->state; } if ($spouse->marriagePlace && isset($spouse->marriagePlace->country)) { $marriagePlace->country = $spouse->marriagePlace->country; } if ($spouse->marriagePlace && isset($spouse->marriagePlace->cemetary)) { $marriagePlace->cemetary = $spouse->marriagePlace->cemetary; } $marriagePlace->ft_name = 'spouse'; $marriagePlace->fkey = $spouseId; $marriageId = $marriagePlace->save(); if ($marriageId) { $newSpouse->place = $marriageId; $newSpouse->save(); } } return $newSpouse->id; }