コード例 #1
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Product::$rules);
     if ($validator->passes()) {
         $product = new Product();
         $product->title = Input::get('title');
         $product->description = Input::get('description');
         $id = Input::get('product_id');
         $skuAsset = sprintf("%06s", $id);
         $product->sku = 'INDE' . $skuAsset;
         $product->category_id = Input::get('category_id');
         $product->subcategory_id = Input::get('subcategory_id');
         $product->price = Input::get('price');
         $product->weight = Input::get('weight');
         $product->supplier_id = Auth::user()->id;
         $product->image = 'images/products/INDE' . $skuAsset;
         $product->save();
         $details = new Detail();
         $details->details = Input::get('details');
         $details->model = Input::get('model');
         $details->brand = Input::get('brand');
         $details->moredescription = Input::get('moredescription');
         $details->product_id = Input::get('product_id');
         $details->save();
         return Response::json('success', 200);
     } else {
         return $validator->errors;
     }
 }
コード例 #2
0
ファイル: stock.php プロジェクト: narendranag/Profectus
 function save_detail()
 {
     $id = $this->input->post("id");
     if ($id == 0) {
         $detailObject = new Detail();
     } else {
         $detailObject = new Detail($id);
     }
     $detailObject->inventory_id = $this->input->post("inventory_id");
     $detailObject->description = $this->input->post("description");
     $detailObject->price = $this->input->post("price");
     $detailObject->save();
     echo $detailObject->id;
 }
コード例 #3
0
ファイル: pagos.php プロジェクト: ricardocasares/Cobros
 public function agregar()
 {
     if ($_POST) {
         $this->load->helper('date');
         $this->load->library('Utils');
         $insert = $_POST;
         $insert['user_id'] = 1;
         $insert['fecha'] = date('Y-m-d');
         $pago = new Payment(elements(array('student_id', 'user_id', 'fecha', 'importe'), $insert));
         if ($pago->is_valid()) {
             $pago->save();
             foreach ($insert['parcial'] as $k => $v) {
                 $detalle = array('debt_id' => $k, 'payment_id' => $pago->id, 'importe' => $v);
                 $d = new Detail($detalle);
                 if ($d->is_valid()) {
                     $d->save();
                 }
             }
             $this->session->set_flashdata('msg', '<div class="success">El pago se realizó correctamente.</div>');
             redirect($this->agent->referrer());
         } else {
             $this->session->set_flashdata('msg', '<div class="error">No pudo procesarse el pago, intente nuevamente.</div>');
         }
     }
 }