I have a polymorphic association that I have set up it goes like this:
Media has a 1-to-1 association with either Photo, Video or Text
an excerpt of the Media model looks like this:
public $hasOne = array(
'Photo' => array(
'className' => 'Photo',
'foreignKey' => 'media_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Text' => array(
'className' => 'Text',
'foreignKey' => 'media_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
Is there a way to specify a condition like
'conditions' => ['LfrMomentArticle.type' => 'photo'],
inside the Photo submodel so that it will not query over all the submodels each time but instead look at the type and then pick the correct submodel?