在查看 InventoryCategory 摘要时,我可以获取 Inventory 但不能获取 InventoryImages。CakePHP 报告的错误是[ Model "Inventory" is not associated with model "InventoryImage" ]。这些是我正在使用的模型:
class InventoryCategory extends InventoriesAppModel {
public $hasMany =
array(
'Inventory'
, 'InventoryCategoryImage' => array
(
'className' => 'Media.MediaImage'
, 'foreignKey' => 'foreign_key'
, 'conditions' => array(
'InventoryCategoryImage.model' => 'InventoryCategoryImage'
, 'InventoryCategoryImage.group' => 'Inventory Category Image'
,
)
, 'dependent' => true
,
)
,
);
public function containedModels()
{
$contain = array(
'Inventory'
, 'InventoryCategoryImage'
,
);
return $contain;
}
}
class Inventory extends InventoriesAppModel {
public $belongsTo =
array(
'User'
, 'InventoryCategory'
,
);
public $hasMany =
array(
'InventoryImage' => array
(
'className' => 'Media.MediaImage'
, 'foreignKey' => 'foreign_key'
, 'conditions' => array(
'InventoryImage.model' => 'InventoryImage'
, 'InventoryImage.group' => 'Inventory Image'
,
)
, 'dependent' => true
, 'order' => 'InventoryImage.rank ASC, InventoryImage.id ASC'
)
,
);
public function containedModels()
{
$contain = array(
'User'
, 'InventoryCategory'
,
);
return $contain;
}
}