本文整理汇总了PHP中Item::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::findOrFail方法的具体用法?PHP Item::findOrFail怎么用?PHP Item::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::findOrFail方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDelete
public function getDelete($item_id)
{
$task = Item::findOrFail($item_id);
if ($task->user_id == Auth::user()->id) {
$task->delete();
}
return Redirect::route('home');
}
示例2: postIndex
public function postIndex()
{
$id = Input::get('id');
$item = Item::findOrFail($id);
if ($item->onwer_id == Auth::user()->id) {
$item->mark();
}
return Redirect::route('home');
}
示例3: 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();
}
$item_id = Input::get('item');
$location_id = Input::get('location');
$item = Item::findOrFail($item_id);
$location = Location::find($location_id);
$quantity = Input::get('quantity');
$date = Input::get('date');
Stock::addStock($item, $location, $quantity, $date);
return Redirect::route('stocks.index')->withFlashMessage('stock has been successfully updated!');
}
示例4: update
/**
* Update the specified item in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$item = Item::findOrFail($id);
$validator = Validator::make($data = Input::all(), Item::$rules, Item::$messages);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$item->name = Input::get('name');
$item->description = Input::get('description');
$item->purchase_price = Input::get('pprice');
$item->selling_price = Input::get('sprice');
$item->sku = Input::get('sku');
$item->tag_id = Input::get('tag');
$item->reorder_level = Input::get('reorder');
$item->update();
return Redirect::route('items.index')->withFlashMessage('Item successfully updated!');
}
示例5: store
/**
* Store a newly created order in storage.
*
* @return Response
*/
public function store()
{
$validation = array('customer' => 'required', 'date' => 'required');
$validator = Validator::make(Input::all(), $validation);
if ($validator->fails()) {
return Redirect::to('orders/create')->withErrors($validator);
} else {
$postorder = Input::all();
$data = array('customer' => $postorder['customer'], 'date' => $postorder['date'], 'total_amount' => $postorder['total_amount'], 'discount' => $postorder['discount'], 'payable_amount' => $postorder['payable_amount'], 'payment' => $postorder['payment'], 'balance' => $postorder['balance']);
$id = DB::table('orders')->insertGetId($data);
for ($i = 0; $i < count($postorder['product_id']); $i++) {
$data_detail = array('product_id' => $postorder['product_id'][$i], 'item' => $postorder['item'][$i], 'quantity' => $postorder['quantity'][$i], 'price' => $postorder['price'][$i], 'amount_charged' => $postorder['amount_charged'][$i], 'Order_id' => $id);
DB::table('order_details')->insert($data_detail);
$date = $postorder['date'];
$location = Location::findOrFail($postorder['location']);
foreach ($data_detail as $item) {
$it = Item::findOrFail($postorder['item'][$i]);
$quantity = $postorder['quantity'][$i];
Stock::removeStock($it, $location, $quantity, $date);
}
}
return Redirect::route('orders.index')->with('success', 'Item Successfully Added');
}
}
示例6: getItem
public function getItem($id)
{
$item = Item::findOrFail($id);
dd("called");
return Redirect::route('employees.index', compact('item'));
}
示例7: show
/**
* Display the specified resource.
* GET /items/{id}
*
* @param int $id
* @return Response
*/
public function show($id)
{
return Item::findOrFail($id);
}
示例8: Erporder
//$orderitems = Session::get('erppurchase');
$erporder = Session::get('erporder');
$orderitems = Session::get('quotationitems');
$total = Input::all();
// $client = Client: :findorfail(array_get($erporder, 'client'));
// print_r($total);
$order = new Erporder();
$order->order_number = array_get($erporder, 'order_number');
$order->client()->associate(array_get($erporder, 'client'));
$order->date = date('Y-m-d', strtotime(array_get($erporder, 'date')));
$order->status = 'new';
//$order->discount_amount = array_get($total, 'discount');
$order->type = 'quotations';
$order->save();
foreach ($orderitems as $item) {
$itm = Item::findOrFail($item['itemid']);
$ord = Erporder::findOrFail($order->id);
$orderitem = new Erporderitem();
$orderitem->erporder()->associate($ord);
$orderitem->item()->associate($itm);
$orderitem->price = $item['price'];
$orderitem->quantity = $item['quantity'];
//s$orderitem->duration = $item['duration'];
$orderitem->save();
}
//Session::flush('orderitems');
//Session::flush('erporder');
return Redirect::to('quotationorders');
});
Route::get('erporders/cancel/{id}', function ($id) {
$order = Erporder::findorfail($id);
示例9: update
/**
* Update the specified item in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$item = Item::findOrFail($id);
$validator = Validator::make($data = Input::all(), Item::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$item->update($data);
return Redirect::route('admin.items.index');
}