public function resolveRecord(): ?Model
{
try {
$address = Address::firstOrCreate([
'street' => $this->data['street'],
'number' => $this->data['number'],
'postcode' => $this->data['postcode'],
'city' => $this->data['city'],
'country' => $this->data['country'],
]);
$company = Company::updateOrCreate([
'company_code' => $this->data['code'],
], [
'name' => $this->data['name'],
'address_id' => $address->id,
'phone_number' => $this->data['phone'],
'email' => $this->data['email'],
'kvk_number' => $this->data['kvk'],
'btw_number' => $this->data['vat'],
]);
return $company;
} catch (\Exception $e) {
throw new RowImportFailedException("not created: " . $e->getMessage());
}
}
public function resolveRecord(): ?Model
{
try {
$address = Address::firstOrCreate([
'street' => $this->data['street'],
'number' => $this->data['number'],
'postcode' => $this->data['postcode'],
'city' => $this->data['city'],
'country' => $this->data['country'],
]);
$company = Company::updateOrCreate([
'company_code' => $this->data['code'],
], [
'name' => $this->data['name'],
'address_id' => $address->id,
'phone_number' => $this->data['phone'],
'email' => $this->data['email'],
'kvk_number' => $this->data['kvk'],
'btw_number' => $this->data['vat'],
]);
return $company;
} catch (\Exception $e) {
throw new RowImportFailedException("not created: " . $e->getMessage());
}
}