Skip to content

Commit

Permalink
Merge pull request #146 from sarapis/feedback-changes
Browse files Browse the repository at this point in the history
Update service import
  • Loading branch information
d9it committed Mar 19, 2024
2 parents 93d99b8 + 5f0f95d commit 9b8d078
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions app/Services/ServiceDataService.php
Expand Up @@ -68,23 +68,13 @@ public function service_airtable_v3($access_token, $base_url)
$service->service_alternate_name = isset($record['fields']['alternative_name']) ? $record['fields']['alternative_name'] : null;
$service->service_description = isset($record['fields']['description']) ? $record['fields']['description'] : null;

if (isset($record['fields']['x-locations'])) {
$i = 0;
foreach ($record['fields']['x-locations'] as $value) {
$service_location = new ServiceLocation();
$service_location->service_recordid = $service->service_recordid;
$service_location->location_recordid = $strtointclass->string_to_int($value);
$service_location->save();
$servicelocation = $strtointclass->string_to_int($value);

if ($i != 0) {
$service->service_locations = $service->service_locations . ',' . $servicelocation;
} else {
$service->service_locations = $servicelocation;
}

$i++;
if (isset($record['fields']['locations'])) {
$serviceLocation = [];
foreach ($record['fields']['locations'] as $value) {
$serviceLocation[] = $strtointclass->string_to_int($value);
}
$service->service_locations = count($serviceLocation) > 0 ? implode(',', $serviceLocation) : null;
$service->locations()->sync($serviceLocation);
}

$service->service_url = isset($record['fields']['url']) ? $record['fields']['url'] : null;
Expand All @@ -93,15 +83,15 @@ public function service_airtable_v3($access_token, $base_url)

$service->service_status = isset($record['fields']['status']) ? $record['fields']['status'] : null;

if (isset($record['fields']['taxonomy_terms'])) {
$i = 0;
$servicetaxonomy = [];
foreach ($record['fields']['taxonomy_terms'] as $value) {
if (isset($record['fields']['taxonomy_terms'])) {
$i = 0;
$servicetaxonomy = [];
foreach ($record['fields']['taxonomy_terms'] as $value) {
// $service_taxonomy = new ServiceTaxonomy();
// $service_taxonomy->service_recordid = $service->service_recordid;
// $service_taxonomy->taxonomy_recordid = $strtointclass->string_to_int($value);
// $service_taxonomy->save();
$servicetaxonomy[] = $strtointclass->string_to_int($value);
$servicetaxonomy[] = $strtointclass->string_to_int($value);

// if ($i != 0) {
// $service->service_taxonomy = $service->service_taxonomy . ',' . $servicetaxonomy;
Expand All @@ -110,9 +100,9 @@ public function service_airtable_v3($access_token, $base_url)
// }

// $i++;
}
$service->service_taxonomy = count($servicetaxonomy) > 0 ? implode(',', $servicetaxonomy) : null ;
}
}
$service->service_taxonomy = count($servicetaxonomy) > 0 ? implode(',', $servicetaxonomy) : null;
}

$service->service_application_process = isset($record['fields']['application_process']) ? $record['fields']['application_process'] : null;
// $service->service_wait_time = isset($record['fields']['wait_time']) ? $record['fields']['wait_time'] : null;
Expand Down

0 comments on commit 9b8d078

Please sign in to comment.