Hello everyone,
I have a bit of a twist on "favorites" that I'm not sure how to handle. I
have a Users model and a ThingFunction model. A user can create a
ThingFunction. Also, I want users to be able to have ThingFunctions as
favorites (which would be a HABTM relationship in a join table
thing_functions_users).
So, for the first part, I use:
ThingFunction model:
var $belongsTo = array(
'User' => array(
'className' => 'User',
'counterCache' => true,
'counterScope' => array ('ThingFunction.is_inappropriate' => 0)
),
);
User model:
var $hasMany = array(
'ThingFunction' => array(
'className' => 'ThingFunction',
'conditions' => 'ThingFunction.is_inappropriate = 0'
)
);
How do I handle the favorites part? Would I just add this to ThingFunction:
var $hasAndBelongsToMany = array('User');
And this in the User model:
var $hasAndBelongsToMany = array('ThingFunction');
If above is correct, then how would I differentiate between ThingFunctions
that belong to a user (created by them) and ThingFunctions that are a User's
favorite?
Any help would be greatly appreciated. Thanks.
Tamim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---