type = $type; } public function save($data = array()) { if(!PackageItemTypeEnum::isValidValue($this->type)) { throw new Exception('Invalid Package Item Type ('. $this->type .')'); } parent::save($data); } public function getPackage() { return new main\models\custom\package\Package($this->packageid); } public function getRelatedItem() { switch ($this->type) { case PackageItemTypeEnum::DOMAIN: return main\models\whmcs\domains\pricing\repository::factory()->byExtension($this->relid)->one(); case PackageItemTypeEnum::PRODUCT: return main\models\whmcs\product\product::factory($this->relid); case PackageItemTypeEnum::ADDON: return main\models\whmcs\addon\addon::factory($this->relid); case PackageItemTypeEnum::OTHER: return new main\mgLibs\custom\relateditem\Other(); } } }