public function load($data) { if (!empty($data)) { $discountCode = new DiscountCode(); $discountCode->setPropertiesFromArray($data); } return $discountCode instanceof DiscountCode ? $discountCode : false; }
public function save() { if ($this->isPost()) { $data = $this->post(); if ($data['drID']) { $this->edit($data['drID']); } $errors = DiscountCode::validate($data); if (!$errors->has()) { $discountrule = DiscountRule::save($data); if ($data['drID']) { $this->redirect('/dashboard/store/discounts/', 'updated'); } else { if ($discountrule->drTrigger == 'code') { $this->redirect('/dashboard/store/discounts/codes/' . $discountrule->drID); } else { $this->redirect('/dashboard/store/discounts/', 'success'); } } } else { $this->error = $errors; } //if no errors } // if post }