Is it somehow possible to create a hasMany Relationship which makes use of an ID outside of the Model? For example one User has many Comments, but I would like to find just the comments of the logged in user:
public $hasMany = array(
'MyComment' => array(
'className' => 'Comment',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => array('Comment.user_id' => $loggedinUser_id),
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
I was thinking of passing the $loggedinUser_id in the controllers beforeFilter() to the model. Is this a good way to solve this issue or are there better ways?
Any suggestion is appreciated. Thanks a lot!