当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::find方法代码示例

本文整理汇总了PHP中app\Item::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::find方法的具体用法?PHP Item::find怎么用?PHP Item::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Item的用法示例。


在下文中一共展示了Item::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->all();
     Item::where("id", $id)->update($input);
     $item = Item::find($id);
     return response($item);
 }
开发者ID:savanihd,项目名称:Laravel-5-Angularjs-CRUD-with-Search-and-Pagination,代码行数:13,代码来源:ItemController.php

示例2: destroy

 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy($id)
 {
     $item = Item::find($id);
     //select the book using primary id
     $item->delete();
     return redirect('/');
 }
开发者ID:xenarax,项目名称:rgg_laravel,代码行数:11,代码来源:ItemController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $item = \App\Item::find($id);
     $item->title = $request->title;
     $item->completed = $request->completed;
     $item->save();
     return $item;
 }
开发者ID:zacksmash,项目名称:angular-app,代码行数:15,代码来源:ResourceController.php

示例4: putItem

 public function putItem(Request $request)
 {
     $this->validate($request, ['id' => 'exists:items', 'descripcion' => 'required|min:5']);
     $item = Item::find($request->get('id'));
     $item->descripcion = $request->get('descripcion');
     $item->save();
     return response()->json($item);
 }
开发者ID:JCarlosR,项目名称:SIL,代码行数:8,代码来源:RitController.php

示例5: sort

 public function sort(Request $itemsOrder)
 {
     $items = explode(',', $itemsOrder->input('list_order'));
     $i = 1;
     foreach ($items as $itemId) {
         $item = Item::find($itemId);
         $item->item_order = $i;
         $item->save();
         $i++;
     }
     return "Order saved";
 }
开发者ID:jurewerk,项目名称:draggproject,代码行数:12,代码来源:ItemController.php

示例6: testDeleteItem

 public function testDeleteItem()
 {
     $user = factory(User::class)->create();
     $item = $this->getFakeItem($user->id);
     $itemtest = Item::find($item->id);
     //// TODO: why is user_id -1 in created object???
     print 'user_id: ' . $user->id . ' category_id: ' . $item->category_id;
     print 'Itemtest: user_id: ' . $itemtest->user_id . ' category_id: ' . $itemtest->category_id;
     $item_criteria = ['name' => $item->name, 'category_id' => $item->category_id];
     $this->seeInDatabase('items', $item_criteria);
     //// create new item
     $this->actingAs($user)->delete('/api/items/' . $item->id);
     $this->notSeeInDatabase('items', $item_criteria);
 }
开发者ID:athill,项目名称:wimf,代码行数:14,代码来源:ItemTest.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(InventoryRequest $request, $id)
 {
     $items = Item::find($id);
     $items->quantity = $items->quantity + Input::get('in_out_qty');
     $items->save();
     $inventories = new Inventory();
     $inventories->item_id = $id;
     $inventories->user_id = Auth::user()->id;
     $inventories->in_out_qty = Input::get('in_out_qty');
     $inventories->remarks = Input::get('remarks');
     $inventories->save();
     Session::flash('message', 'You have successfully updated item');
     return Redirect::to('inventory/' . $id . '/edit');
 }
开发者ID:irfanmg,项目名称:tutapos,代码行数:20,代码来源:InventoryController.php

示例8: show

 public function show($id)
 {
     //temporarily restore the item
     Item::withTrashed()->where('id', $id)->restore();
     $item = Item::find($id);
     if ($item->user_id == \Auth::user()->id) {
         \Session::flash('flash_message', 'The item has been recovered.');
     } else {
         //delete it again if not authorized
         $item->delete();
         \Session::flash('flash_message', "You aren't authorized to recover this item.");
     }
     return redirect('items');
 }
开发者ID:chrisguo1,项目名称:To-Do-List,代码行数:14,代码来源:RestoreController.php

示例9: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['category_id' => 'required', 'name' => 'required', 'description' => 'required', 'cost' => 'required']);
     $item = Item::find($id);
     $item->category_id = $request->input('category_id');
     $item->name = $request->input('name');
     $item->description = $request->input('description');
     $item->cost = $request->input('cost');
     if ($request->hasFile('image')) {
         $extension = $request->file('image')->getClientOriginalExtension();
         $item->image_type = $extension;
         $storage = Storage::disk('s3')->put('/items/' . $item->id . '.' . $extension, file_get_contents($request->file('image')->getRealPath()), 'public');
     }
     $item->save();
     return redirect('items')->with('flash_message', 'Item details updated');
 }
开发者ID:robboyland,项目名称:ecom,代码行数:23,代码来源:ItemsController.php

示例10: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     switch ($this->method()) {
         case 'POST':
             return ['name' => 'required|unique:items', 'unit' => 'required'];
         case 'PATCH':
             $item = Item::find($this->segment(2));
             //this gets the second segment in the url which is the id of the item
             if ($this->get('name') == $item['name']) {
                 return ['name' => 'required|unique:items,id' . $this->get('id'), 'unit' => 'required'];
             } else {
                 return ['name' => 'required|unique:items', 'unit' => 'required'];
             }
         default:
             break;
     }
 }
开发者ID:jacqhernandez,项目名称:hsms,代码行数:22,代码来源:CreateItemRequest.php

示例11: postAddToCart

 public function postAddToCart(Request $request)
 {
     $this->validate($request, ['item' => 'required|numeric|exists:items,id']);
     $user_id = Auth::user()->id;
     $item_id = Input::get('item');
     $amount = 1;
     $item = Item::find($item_id);
     $total = $amount * $item->price;
     $carts = Cart::with('Items')->where('user_id', $user_id)->get();
     $item_stock = $item->stock;
     if ($item->stock < 1) {
         return redirect('/')->withErrors('Ce produit n\'est plus disponible');
     }
     Cart::create(['user_id' => $user_id, 'item_id' => $item_id, 'amount' => $amount, 'total' => $total]);
     $item->decrement('stock');
     $last_timestamp = Cart::with('Items')->where('user_id', $user_id)->orderBy('created_at', 'desc')->first()->created_at;
     Auth::user()->last_cart_timestamp = $last_timestamp;
     Auth::user()->save();
     return redirect('/');
 }
开发者ID:starmatt,项目名称:webpapa,代码行数:20,代码来源:CartController.php

示例12: show

 public function show($id)
 {
     $edificio_id = Input::get('id');
     $edificio = Edificio::find($edificio_id);
     $administrador = Administrador::find($edificio->admin_id);
     $items = Item::find($id);
     //obtengo el id de la espensa que vien por la url//
     $exp_uri = $_SERVER["REQUEST_URI"];
     $exp_uri = explode('/', $exp_uri);
     $exp_uri = explode('?', $exp_uri[4]);
     $exp_id = $exp_uri[0];
     $expensa = new Expensa();
     $expensa = $expensa::find($exp_id);
     $pisos = DB::table('items')->join('propietarios', 'propietarios.id', '=', 'items.unidad_id')->where('items.expensa_id', '=', $id)->get();
     if (Auth::user()->rol_id == 2) {
         //return View::make('administrador.expensas.show')
         //->with('items', $items)
         //->with('edificio', $edificio)
         //->with('admin', $administrador)
         //->with('pisos', $pisos);
         $view = \View::make('administrador.expensas.show')->with('items', $items)->with('edificio', $edificio)->with('admin', $administrador)->with('pisos', $pisos)->with('expensa', $expensa);
         $pdf = \App::make('dompdf.wrapper');
         $pdf->loadHTML($view);
         return $pdf->stream('Expensa.pdf');
     }
     if (Auth::user()->rol_id == 3) {
         $view = \View::make('propietario.expensas.show')->with('items', $items)->with('edificio', $edificio)->with('admin', $administrador)->with('pisos', $pisos)->with('expensa', $expensa);
         $pdf = \App::make('dompdf.wrapper');
         $pdf->loadHTML($view);
         return $pdf->stream('Expensa.pdf');
         //return View::make('propietario.expensas.index');
     }
     if (Auth::user()->rol_id == 4) {
         $view = \View::make('inquilino.expensas.show')->with('items', $items)->with('edificio', $edificio)->with('admin', $administrador)->with('pisos', $pisos)->with('expensa', $expensa);
         $pdf = \App::make('dompdf.wrapper');
         $pdf->loadHTML($view);
         return $pdf->stream('Expensa.pdf');
         //return View::make('propietario.expensas.index');
     }
 }
开发者ID:danielrolonbenitez,项目名称:vertical,代码行数:40,代码来源:ExpensasController.php

示例13: add

 /**
  * @param Request $request
  * this function is for adding products to the shopping cart
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function add(Request $request)
 {
     if ($request->isMethod('post')) {
         $item_id = $request->get('item_id');
         $has_item = false;
         $item = Item::find($item_id);
         $cat_name = $request->get('catName');
         if (Session::has('items')) {
             foreach ($request->session()->get('items') as $items) {
                 if ($items['id'] == $item_id) {
                     $has_item = true;
                 }
             }
         }
         if (!$has_item) {
             $request->session()->push('items', ['id' => "{$item->itID}", 'quantity' => 1, 'name' => "{$item->itName}", 'price' => "{$item->price}", 'imgpath' => "{$item->imName}"]);
         }
         //$request->session()->flush();
         //retrieve the session array
         $data = $request->session()->get('items');
         return view('pages.cart.cart', compact('data', 'i', 'n', 'cat_name'));
     }
 }
开发者ID:Legolas000,项目名称:PaintBuddy,代码行数:28,代码来源:CartHandle.php

示例14: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Item::find($id);
     $item->delete();
     return;
 }
开发者ID:avlima,项目名称:laravel-event-broadcasting,代码行数:12,代码来源:ItemController.php

示例15: changePictures

 /**
  * Change the pictures of an item
  *
  * @param  int  $id
  * @param  File $picture1
  * @param  File $picture2
  * @param  bool $dp2
  * @return Response
  */
 public function changePictures()
 {
     $item = Item::find(Request::input('id'));
     // Delete the secondary picture first
     if (Request::has('dp2') && Request::input('dp2') == "true" || Request::file('picture2')) {
         File::delete('uploads/' . $item->hash . '_2.jpg');
         $item->picture2 = false;
     }
     if (Request::file('picture1')) {
         $destination = 'uploads';
         // Give it a unique filename
         $extension = Input::file('picture1')->getClientOriginalExtension();
         if (strtolower($extension) != 'jpg') {
             return Response::make("Please upload only .jpg files.", 400);
         } else {
             $filename = $item->hash . "_1." . strtolower($extension);
             File::delete('uploads/' . $item->hash . '_1.jpg');
             Input::file('picture1')->move($destination, $filename);
         }
     }
     if (Request::file('picture2')) {
         $destination = 'uploads';
         // Give it a unique filename
         $extension = Input::file('picture2')->getClientOriginalExtension();
         if (strtolower($extension) != 'jpg') {
             return Response::make("Please upload only .jpg files.", 400);
         } else {
             $filename = $item->hash . "_2." . strtolower($extension);
             Input::file('picture2')->move($destination, $filename);
         }
         $item->picture2 = true;
     }
     $item->save();
     return Response::make("Success", 205);
 }
开发者ID:BrynnLawson,项目名称:smarka,代码行数:44,代码来源:ItemsController.php


注:本文中的app\Item::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。