public function loadShopItemsPacksModel($id) { $model = ShopItemsPacks::model()->findByPk($id); if (!$model) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function afterDelete() { parent::afterDelete(); Yii::import('application.modules.cabinet.models.ShopItemsPacks'); Yii::import('application.modules.cabinet.models.ShopItems'); $criteria = new CDbCriteria(array('condition' => 'category_id = :category_id', 'params' => array(':category_id' => $this->getPrimaryKey()), 'with' => array('items'))); $model = ShopItemsPacks::model()->findAll($criteria); foreach ($model as $pack) { foreach ($pack->items as $item) { $item->delete(); } $pack->delete(); } }