In associations in CakePHP by default it always makes the relationship being the model name in the singular followed by _id, that is, model_id.
Is it possible to change this relationship key to another table field?
I tried to use foreignKey
but it did not work.
Below the two models:
<?php
class Cart_item extends AppModel
{
public $name = 'Cart_item';
}
?>
E Cart:
<?php
class Cart extends AppModel
{
public $name = 'Cart';
public $hasMany = array(
'Cart_item' => array(
'className' => 'Cart_item',
'foreignKey' => 'Cart_uid'
)
);
}
?>