Skip to content

Commit

Permalink
Merge pull request #1866 from bakaphp/development
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken authored Aug 27, 2024
2 parents 0f75fcf + 5927a63 commit c1cdc56
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Kanvas\Guild\Customers\Models\PeopleEmploymentHistory;
use Kanvas\Guild\Organizations\Actions\CreateOrganizationAction;
use Kanvas\Guild\Organizations\DataTransferObject\Organization;
use Kanvas\Guild\Organizations\Models\OrganizationPeople;
use Kanvas\Locations\Models\Countries;
use Kanvas\Locations\Models\States;
use Spatie\LaravelData\DataCollection;
Expand Down Expand Up @@ -66,6 +67,9 @@ private function processPeopleData(Model $people, AppInterface $app, array $peop
$peopleDto = $this->buildPeopleDto($people, $app, $peopleData, $contacts, $address);

(new UpdatePeopleAction($people, $peopleDto))->execute();
if (! empty($peopleData['organization'])) {
$this->setOrganization($people, $app, $peopleData['organization']);
}
$this->updateEmploymentHistory($people, $app, $peopleData['employment_history']);
$this->updateTodayReport($people, ! empty($peopleData['employment_history']));
}
Expand Down Expand Up @@ -111,6 +115,26 @@ private function updateTodayReport(Model $people, bool $successExtraction): void
$people->set(ConfigurationEnum::APOLLO_DATA_ENRICHMENT_CUSTOM_FIELDS->value, time());
}

private function setOrganization(Model $people, AppInterface $app, array $organization): void
{
if (empty($organization['name'])) {
return;
}

$organization = (new CreateOrganizationAction(
new Organization(
$people->company,
$people->user,
$app,
$organization['name']
)
))->execute();

OrganizationPeople::addPeopleToOrganization($organization, $people);

$people->set('company', $organization['name']);
}

private function updateEmploymentHistory(Model $people, AppInterface $app, array $employmentHistory): void
{
foreach ($employmentHistory as $employment) {
Expand Down

0 comments on commit c1cdc56

Please sign in to comment.