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


PHP Item::findOrFail方法代码示例

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


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

示例1: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $bomhead = Bomhead::findOrNew($id);
     $parentItem = Item::findOrFail($id);
     $bomitems = Bomitem::latest('created_at')->where('parent_item_id', $id)->with('parentitem')->get();
     return view('boms.edit', compact('bomhead', 'parentItem', 'bomitems'));
 }
开发者ID:seahouse,项目名称:la514test,代码行数:14,代码来源:BomsController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['id' => 'required']);
     $item = Item::findOrFail($id);
     $item->update($request->all());
     Session::flash('flash_message', 'Item successfully updated!');
     return redirect('item');
 }
开发者ID:fauzanrazandi16,项目名称:Project,代码行数:14,代码来源:ItemController.php

示例3: unlike

 public function unlike($item, $userId)
 {
     $item = Item::findOrFail($item);
     if ($item->unlike($userId)) {
         event(new UserUnlikedAnItem($item));
         return 'You unliked an item.';
     }
     return 'There was a problem unliking a post.';
 }
开发者ID:marktimbol,项目名称:sell-used-items,代码行数:9,代码来源:ItemsController.php

示例4: delete

 public function delete(Request $request)
 {
     $item = Item::findOrFail($request->id);
     $item->delete_stat = 1;
     $item->save();
     $itemid = $item->id;
     $employeeid = Auth::user()->id;
     $logs = ActivityLog::create(['employee_id' => $employeeid, 'activity' => 'Delete Item', 'table_affected' => 'item', 'primary_key' => $itemid, 'column_affected' => 'remove_stat']);
     return redirect()->route('erp_system.item.index')->withSuccess('Item deleted.');
 }
开发者ID:husseinsbm,项目名称:erp-system-prototype,代码行数:10,代码来源:ItemController.php

示例5: postIndex

 public function postIndex()
 {
     $id = Input::get('id');
     //findOrFail is a method provided by Eloquent (in item model)
     $item = Item::findOrFail($id);
     if ($item->owner_id == Auth::user()->id) {
         //only mark it when the logged in user is the owner
         $item->mark();
     }
     return Redirect::route('home');
 }
开发者ID:Verhoevenwout,项目名称:web-backend-oplossingen,代码行数:11,代码来源:HomeController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $item = Item::findOrFail($id);
     $item = $this->getRequestItem($request, $item);
     //// category object
     $category = new Category();
     $category->name = $request->get('category');
     $category->container_id = $request->get('container_id');
     $item = Item::persist($item, $category)->toArray();
     $item['category'] = $category->name;
     return $item;
 }
开发者ID:athill,项目名称:wimf,代码行数:18,代码来源:ItemController.php

示例7: toggleDone

 public function toggleDone($id)
 {
     $item = Item::findOrFail($id);
     if ($item->status == 0) {
         $item->status = 1;
         $item->update();
         return true;
     } else {
         $item->status = 0;
         $item->update();
         return true;
     }
     return false;
 }
开发者ID:xenarax,项目名称:rgg_laravel,代码行数:14,代码来源:ItemController.php

示例8: markAsFavorite

 /**
  * [markAsFavorite mark a podcast item as favorite]
  * @return array
  */
 public function markAsFavorite()
 {
     $result['status'] = 0;
     $result['message'] = 'Something went wrong, please try again';
     $itemId = trim(strip_tags(Request::get('itemId')));
     $item = DB::table('items')->select('user_id')->where('user_id', '=', Auth::user()->id)->where('id', '=', $itemId)->first();
     // if item with id exists in DB and is owned by the authenticated user
     if ($item) {
         $podcastItem = Item::findOrFail($itemId);
         $result['currentValue'] = !$podcastItem->is_mark_as_favorite;
         $podcastItem->is_mark_as_favorite = !$podcastItem->is_mark_as_favorite;
         // opposite of current value
         $podcastItem->save();
         $result['status'] = 1;
         $result['message'] = 'This item has been updated';
     }
     return $result;
 }
开发者ID:MehmetNuri,项目名称:Podcastwala,代码行数:22,代码来源:ItemController.php

示例9: getFiles

 public function getFiles(ItemRequest $request)
 {
     $item = Item::findOrFail($request->get('item_id'));
     $list = [];
     $size = 0;
     //        foreach ($item->items as $item) {
     //            $list[] = [
     //                'file' => $item->title,
     //                'path' => $item->path,
     //                'id' => $item->id,
     //            ];
     //        }
     foreach ($item->files()->get() as $file) {
         $size += $file->size;
         $list[] = ['file' => $file->filename, 'path' => "{$item->path}/{$file->filename}", 'size' => $this->formatBytes($file->size)];
     }
     return response()->json(['files' => $list, 'count' => count($list), 'size' => $this->formatBytes($size)]);
 }
开发者ID:bagf,项目名称:laravel-file-search,代码行数:18,代码来源:ItemController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $item = \App\Item::findOrFail($id);
     $item->delete();
     return 'The resource #' . $id . ' was deleted';
 }
开发者ID:zacksmash,项目名称:angular-app,代码行数:12,代码来源:ResourceController.php

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(ItemRequest $request, $id)
 {
     $item = Item::findOrFail($id);
     $item->update($request->all());
     $prices = Price::where('item_id', '=', $id)->orderBy('sellable')->get();
     foreach ($prices as $price) {
         if ($price->custom_price < $item->minimum_price) {
             $price->sellable = 0;
             $price->save();
         } else {
             $price->sellable = 1;
             $price->save();
         }
         if ($price->is_custom == '0') {
             $price->custom_price = $item->price;
             $price->save();
         }
     }
     return redirect('item')->with('message', 'Data berhasil dirubah!');
 }
开发者ID:Herlanggaws,项目名称:givani,代码行数:27,代码来源:ItemsController.php

示例12: show

 /**
  * 
  * Show - Show the contents of a particular item
  * Parameter - Id # of specific item 	  
  */
 public function show($id)
 {
     $item = Item::findOrFail($id);
     return view('items.show', compact('item'));
 }
开发者ID:sgottenyc,项目名称:laravel_login,代码行数:10,代码来源:ItemsController.php

示例13: 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)
 {
     $data = $request->except('_token');
     $item = Item::findOrFail($id);
     $path = 'images/items/';
     $destinationPath = public_path($path);
     if ($request->hasFile('image_url')) {
         $name = $request->file('image_url')->getClientOriginalName();
         $request->file('image_url')->move($destinationPath, $name);
         $item->image_url = $path . $name;
     }
     $item->name = $data['name'];
     $item->status = (int) $data['status'];
     $item->qualtity = $data['quantity'];
     $item->save();
     return redirect()->route('admin.item.show', $item->id)->with(['message' => 'success!']);
 }
开发者ID:louisthaihv,项目名称:colong,代码行数:24,代码来源:ItemController.php

示例14: update

 public function update($id, ItemRequest $request)
 {
     $item = Item::findOrFail($id);
     $item->update($request->all());
     return redirect('items');
 }
开发者ID:suxiid,项目名称:application,代码行数:6,代码来源:ItemsController.php

示例15: edit

 public function edit(Requests\UpdateItemRequest $request)
 {
     $item = Item::findOrFail($request->item_id);
     return view('product.edititem', compact('item'));
 }
开发者ID:pius-ng3a,项目名称:go_orderdeliver,代码行数:5,代码来源:ProductController.php


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