Update the method, saveMap, for CompanyAPI to save a city as parent.
This commit is contained in:
@@ -16,18 +16,21 @@ class CompanyAPI extends AbstractItemAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function saveMap($companies, $city = null) {
|
public function saveMap($companies, $city = null) {
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company_json) {
|
||||||
$uuid = $company['id'];
|
$uuid = $company_json['id'];
|
||||||
$name = $company['name'];
|
$name = $company_json['name'];
|
||||||
$image = $company['image'] ?? '';
|
$image = $company_json['image'] ?? '';
|
||||||
$description = $company['description'] ?? '';
|
$description = $company_json['description'] ?? '';
|
||||||
|
|
||||||
Company::firstOrCreate([
|
$company = Company::firstOrCreate([
|
||||||
'uuid' => $uuid,
|
'uuid' => $uuid,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'image' => $image,
|
'image' => $image,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if($city != null)
|
||||||
|
$city->addCompanyId($company->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user