I have a few models I'm trying to relate.
One model is Item
, one is Slide
, and another is Asset
.
Items have multiple slides beneath them. Assets are basically files that have been uploaded (images, mp3s, etc) and slides are where assets are displayed. Each slide has one asset, but a given asset might belong to multiple slides. A slide has an asset_id
field defined.
I currently have the models defined as:
Slide
class Slide extends AppModel {
var $name = 'Slide';
var $order = array("Slide.order" => "asc");
var $belongsTo = 'Item';
var $hasOne = array(
'Asset' => array(
'className' => 'Asset',
'foreignKey' => 'id',
'dependent' => false
)
);
} // Slide class
Asset
class Asset extends AppModel {
var $name = 'Asset';
var $displayField = 'name';
var $belongsTo= array(
'Assetdir' => array(
'className' => 'Assetdir',
'foreignKey' => 'assetdir_id'
),
'Slide' => array(
'className' => 'Slide',
'foreignKey' => 'id'
)
);
} // Asset class
When I load a slide, I'm seeing its parent element, Item, come through in the returned data, but the associated asset is not. What am I doing wrong here?