При просмотре сводки InventoryCategory я могу получить Inventory, но не InventoryImages. Ошибка, отмеченная CakePHP, - это [Модель «Инвентарь» не связана с моделью «InventoryImage»]. Эти модели я использующие:CakePHP Model Extended Association
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;
}
}
Является ' 'рекурсивным' => 2' в вашей находке() вызов? Кроме того, отправьте запрос на поиск, который даст вам эту ошибку. – Costa
Нет. Я не использую рекурсивный. Содержите вместо этого. – radarhill
'code'public вид функции() { если { \t $ this-> перенаправлять ($ this-> реферер()) ($ this-> PARAMS [ 'ID']!); } $ условия \t = (is_numeric ($ this-> params ['id'])) \t ? array ($ this-> modelClass. '.id =' => $ this-> params ['id']) \t \t \t: array ($ this-> modelClass. '.slug =' => $ this-> params ['id']); $ пункт \t \t = $ это -> {$ this-> modelClass} -> находка ( \t \t \t 'первый' \t \t \t, массив ( \t \t \t \t 'условия' \t => $ условия \t \t \t \t, 'содержит' \t => $ это -> {$ this-> modelClass} -> containedModels() \t \t \t) \t); $ this-> set (compact ('item')); } 'code' – radarhill