public function update(models\ModelAbstract $tariff) { if (!$tariff instanceof TariffPlanLifeCycleModel && !$tariff instanceof TariffPlanServicesModel) { throw new AppEx\InvalidArgumentException('Supplied data must be a tariff model'); } if (!strlen((string) $tariff->getId())) { throw new AppEx\InvalidArgumentException('Supplied tariff model must have Id'); } // Make sure that defaultTermVoice/T2SModified has a value if ($tariff instanceof TariffPlanServicesModel) { if ($tariff->getDefaultTermVoice()->getT2SModified() == null) { if ($tariff->getDefaultTermVoice()->getT2S() == null) { $tariff->getDefaultTermVoice()->setT2S(0); } $tariff->getDefaultTermVoice()->setT2SModified($tariff->getDefaultTermVoice()->getT2S()); } //Zone Plan, $this->_createZonePlan($tariff); } $valid = $this->validate($tariff, true); $tariff->save(); if ($tariff instanceof TariffPlanLifeCycleModel) { \App::audit('Updated life cycle tariff with Id ' . $tariff->getId(), $tariff); } else { \App::audit('Updated services tariff with Id ' . $tariff->getId(), $tariff); } return $tariff->getId(); }