Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions en/orm/associations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,26 @@ If you want to break different addresses into multiple associations, you can do
{
public function initialize(array $config): void
{
$this->hasOne('HomeAddress', [
$this->hasOne('HomeAddresses', [
'className' => 'Addresses'
])
->setProperty('home_address')
->setConditions(['HomeAddress.label' => 'Home'])
->setConditions(['HomeAddresses.label' => 'Home'])
->setDependent(true);

$this->hasOne('WorkAddress', [
$this->hasOne('WorkAddresses', [
'className' => 'Addresses'
])
->setProperty('work_address')
->setConditions(['WorkAddress.label' => 'Work'])
->setConditions(['WorkAddresses.label' => 'Work'])
->setDependent(true);
}
}

.. note::

If a column is shared by multiple hasOne associations, you must qualify it with the association alias.
In the above example, the 'label' column is qualified with the 'HomeAddress' and 'WorkAddress' aliases.
In the above example, the 'label' column is qualified with the 'HomeAddresses' and 'WorkAddresses' aliases.

Possible keys for hasOne association arrays include:

Expand Down