/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); $validation = Validator::make($input, Stock::$rules); if ($validation->passes()) { $this->stock->create($input); return Redirect::route('stocks.index'); } return Redirect::route('stocks.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.'); }
public function addAction() { // create a new model instance //////////////////////////////////////////////////////////// $xi = 0; if (Input::has('index')) { $xi = Input::get("index"); } ///////////////////////////////////////////////////////////// $stockObjnew = new Stock(); if ($stockObjnew->isPosted()) { $new = Input::all(); // attempt validation if ($stockObjnew->validate($xi, $new, 1)) { $object = Stock::create([Stock::$FieldsName[Stock::$FieldsOrderCreate['1']] => Input::get($this->FieldsCreate['1']['name'] . $xi), Stock::$FieldsName[Stock::$FieldsOrderCreate['2']] => Input::get($this->FieldsCreate['2']['name'] . $xi), Stock::$FieldsName[Stock::$FieldsOrderCreate['3']] => Input::get($this->FieldsCreate['3']['name'] . $xi)]); return Response::json(['success' => true, 'iddelrow' => Input::get('index')]); } else { $this->errors = $stockObjnew->errors(); $this->addrow = $this->addrowAction(); return Response::json(['success' => false, 'error' => $this->errors->toArray()]); } } $this->addrow = $this->addrowAction(); $object; $xi = 0; return View::make($this->routeAdd, ["row" => $this->addrow, "FieldsCreate" => $this->FieldsCreate, "module" => $this->module, "productoCombo" => $this->productoCombo, "key" => $this->key]); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Stock::create([]); } }
public function run() { $object = [["ID_PRODUCTO" => "10", "CANTIDAD" => "101", "ID_BODEGA" => "1"], ["ID_PRODUCTO" => "20", "CANTIDAD" => "10", "ID_BODEGA" => "1"], ["ID_PRODUCTO" => "1", "CANTIDAD" => "55", "ID_BODEGA" => "1"]]; DB::unprepared('ALTER TABLE ' . $this->table . ' AUTO_INCREMENT = 1'); foreach ($object as $detail) { Stock::create($detail); } }
/** * Store a newly created stock in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Stock::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } Stock::create($data); return Redirect::route('stocks.index'); }
private function saveInStockTable($disminuir, $idBranch, $idArticle, $amount) { try { $articleStock = Stock::where('article_id', $idArticle)->where('branch_id', $idBranch)->first(); if (!empty($articleStock)) { if ($disminuir == true) { $articleStock->stock -= $amount; } else { $articleStock->stock += $amount; } $articleStock->update(); } else { $StockTable = new Stock(); $stock['branch_id'] = $idBranch; $stock['article_id'] = $idArticle; $stock['stock'] = $amount; $stock['minstock'] = 0; $StockTable->create($stock); } #if } catch (Exception $e) { die('No se pudo modificar el stock del artículo' . $idArticle . ' en la sucursal ' . $idBranch); } }