在我的 Cake 应用程序中,我在用户模型上与自身建立了多种关系,例如喜欢、认可、友谊等。
然而,Cake 似乎不喜欢我这样做的方式,因为我在数组中多次重复了“用户”。那我该怎么做呢?
public $hasAndBelongsToMany = array(
'User'=>array(
'className' => 'User',
'joinTable' => 'friends',
'with' => 'Friend',
'foreignKey' => 'user_id',
'associationForeignKey' => 'friend_id'
),
'User'=>array(
'className' => 'User',
'joinTable' => 'endorsements',
'with' => 'Endorsement',
'foreignKey' => 'user_id',
'associationForeignKey' => 'endorsed_id'
),
'Interest' => array('with' => 'InterestUser')
);