Reputation: 3083
I'm brand new to MVC frameworks and I'm having some issues wrapping my head around how exactly this would be defined in the model.
`UserA` purposes `Offer1`
`UserB` sees and accepts `Offer1`
`Offer` is now complete
I originally had the two sets of users in different tables but that meant a lot of extra work when I think there is probably a simpler way.
Upvotes: 0
Views: 30
Reputation: 19909
You'll have three tables. If you're following CakePHP table naming conventions, you'll probably call them users
, offers_users
and offers
. In this case, you're probably looking to use a hasAndBelongsToMany relationship (HABTM). Basic example
class User extends AppModel {
public $hasAndBelongsToMany = array(
'Offer' =>
array(
'className' => 'Offer',
'joinTable' => 'offers_users',
'foreignKey' => 'user_id',
'associationForeignKey' => 'offer_id',
'unique' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'with' => ''
)
);
}
Upvotes: 2