本文整理汇总了PHP中Stock::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Stock::create方法的具体用法?PHP Stock::create怎么用?PHP Stock::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stock
的用法示例。
在下文中一共展示了Stock::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* 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.');
}
示例2: addAction
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]);
}
示例3: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Stock::create([]);
}
}
示例4: run
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);
}
}
示例5: store
/**
* 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');
}
示例6: saveInStockTable
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);
}
}