ImportAction filling relational data from multiple columns

HI, I am making an importer for standard company table of my projects.
Each company has an invoice and regular address.

I saw the resolveUsing but this only allows you to resolve using the state of one field. For address relation I need to check for multiple fields.

I tried resolving the following:
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());
    }
}


However this still tries to insert all the ImportColumns into company, even street, number etc... while these fields are not in my company model. Am I missing something here? I thought reading the docs very carefully that this was the way to go. I inserted a screenshot with my import columns.

In my log file it tries to insert all the data found and returns the following update:
update `companies` set `company_code` = NL, `street` = XXX, `number` = XXX, `postcode` = XXX, `city` = XXX, `country` = NL, `phone` = ?, `kvk` = ?, `vat` = ?, `companies`.`updated_at` = 2024-12-10 12:43:19 where `id` = 12


Clearly mixing the address table and company table. Does anyone have something like this working? Thanks in advance!
Screenshot_2024-12-10_at_13.45.04.png
Was this page helpful?