Employees
table has a field named current_address_id
. I'm adding a new address to Addresses
like:
$updatedEntity = $this->patchEntity($employee, [
//some other fields
'user' => $userData,
'employees_phones' => $phonesData,
'employees_addresses' => $addressesData,
], [
'associated' => ['Users', 'EmployeesPhones', 'EmployeesAddresses']
]);
$this->save($updatedEntity);
I'm inserting the new address successfully but now I need to update Employees.current_address_id
with the new address ID. How can I do this?
Table::save()
returns the entity with updated ids. So store the return value in a variable and use appropriate property of the entity.