public function post()
 {
     $post = Input::all();
     $validator = Product::validate($post);
     $productId = $post['id'];
     if ($validator->fails()) {
         return Redirect::to('productos/' . $productId)->withErrors($validator)->withInput();
     } else {
         $product = self::__checkExistence($productId);
         $isNew = false;
         if (!$productId) {
             $product = new Product();
             $isNew = true;
         }
         $product->name = $post['name'];
         $product->description = $post['description'];
         $product->code = $post['code'];
         $product->minimum_stock = $post['minimum_stock'];
         $product->cost = str_replace(',', '.', $post['cost']);
         $product->save();
         if ($isNew) {
             Globals::triggerAlerts(4, array('productId' => $product->id));
         }
         if ($post['status'] == 'inactive') {
             $product->delete();
         } else {
             if ($product->trashed()) {
                 $product->restore();
             }
         }
         Session::flash('success', 'Producto guardado correctamente.');
         return Redirect::to('productos');
     }
 }