本文整理匯總了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);
}