本文整理汇总了PHP中Stock::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Stock::findOrFail方法的具体用法?PHP Stock::findOrFail怎么用?PHP Stock::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stock
的用法示例。
在下文中一共展示了Stock::findOrFail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified stock in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$stock = Stock::findOrFail($id);
$validator = Validator::make($data = Input::all(), Stock::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$stock->update($data);
return Redirect::route('stocks.index');
}
示例2: update
/**
* Update the specified stock in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$stock = Stock::findOrFail($id);
$validator = Validator::make($data = Input::all(), Stock::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$stock->item = Input::get('item');
$stock->selling_price = Input::get('selling_price');
$stock->purchase_price = Input::get('purchase_price');
$stock->quantity = Input::get('quantity');
$stock->status = Input::get('status');
$stock->account = Input::get('account');
$stock->update();
return Redirect::route('purchases.index');
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$stock = $this->stock->findOrFail($id);
return View::make('stocks.show', compact('stock'));
}
示例4: deleteAction
public function deleteAction()
{
$stockObjnew = new Stock();
$new = Input::all();
if ($stockObjnew->validate(Input::get($this->key), $new, 3)) {
$object = Stock::findOrFail(Input::get($this->key));
$object->delete();
}
return Redirect::route($this->routeIndex);
}