コード例 #1
0
ファイル: products.php プロジェクト: mehulsbhatt/volcano
 /**
  * Creates a product.
  *
  * @return void
  */
 public function post_index()
 {
     $validator = \Validation_Product::create();
     if (!$validator->run()) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $product = \Service_Product::create($data['name'], \Seller::active(), $data);
     if (!$product) {
         throw new HttpServerErrorException();
     }
     $this->response($product);
 }
コード例 #2
0
ファイル: products.php プロジェクト: mehulsbhatt/volcano
 /**
  * POST Create action.
  *
  * @return void
  */
 public function post_create()
 {
     $this->get_create();
     $validator = Validation_Product::create();
     if (!$validator->run()) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $data = $validator->validated();
     if (!Service_Product::create($data['name'], Seller::active(), $data)) {
         Session::set_alert('error', 'There was an error adding the product.');
         return;
     }
     Session::set_alert('success', 'The product has been added.');
     Response::redirect('products');
 }