Ejemplo n.º 1
0
 /**
  * Updates a product option fee.
  *
  * @param int $option_id Product option ID.
  * @param int $id        Product option fee ID.
  *
  * @return void
  */
 public function put_index($option_id = null, $id = null)
 {
     $option = $this->get_option($option_id);
     $fee = $this->get_fee($id, $option);
     $validator = \Validation_Product_Option_Fee::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $fee = \Service_Product_Option_Fee::update($fee, $data);
     if (!$fee) {
         throw new HttpServerErrorException();
     }
     $this->response($fee);
 }
Ejemplo n.º 2
0
 /**
  * POST Edit action.
  *
  * @param int $option_id Product option ID.
  * @param int $id        Product option fee ID.
  *
  * @return void
  */
 public function post_edit($option_id = null, $id = null)
 {
     $this->get_edit($option_id, $id);
     $validator = Validation_Product_Option_Fee::update();
     if (!$validator->run()) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $option = $this->get_option($option_id);
     $fee = $this->get_fee($id);
     $data = $validator->validated();
     if (!Service_Product_Option_Fee::update($fee, $data)) {
         Session::set_alert('error', 'There was an error updating the product option fee.');
         return;
     }
     Session::set_alert('success', 'The product option fee has been updated.');
     Response::redirect($option->link('fees'));
 }