You have two associations between the User and the ThingFunction
model:
- the owner association is - User hasMany ThingFunction -
ThingFunction belongsTo User.
- the favorites association is - User hasAndBelongsToMany
ThingFunction and vice verse.

Hope this helps you on the way :)
Enjoy,
   John

On Oct 16, 9:22 pm, "Tamim A." <[email protected]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to