當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::findOrFail方法代碼示例

本文整理匯總了PHP中app\models\Item::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::findOrFail方法的具體用法?PHP Item::findOrFail怎麽用?PHP Item::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Item的用法示例。


在下文中一共展示了Item::findOrFail方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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 = Item::findOrFail($id);
     foreach (array_keys(array_except($this->fields, ['item'])) as $field) {
         $item->{$field} = $request->get($field);
     }
     $item->save();
     return redirect("/admin/item/{$id}/edit")->withSuccess("修改完成!");
 }
開發者ID:cdandy,項目名稱:meta-admin,代碼行數:16,代碼來源:ItemController1.php

示例2: updateTableActions

 /**
  * Ajax call for update favorite column
  *
  * @param Request $request
  * @return array
  */
 public function updateTableActions(Request $request)
 {
     if ($request->get('action') == 'favorite') {
         $item = Item::findOrFail($request->get('book-id'));
         $favorite = !$item->favorite;
         $item->update(['favorite' => $favorite]);
         if ($item->favorite) {
             $data['sweetalert'] = ['title' => 'το βιβλίο προστέθηκε στα Αγαπημένα', 'level' => 'success'];
         } else {
             $data['sweetalert'] = ['title' => 'το βιβλίο ΔΕΝ ανήκει πλέον στα Αγαπημένα', 'level' => 'info'];
         }
         $data['itemId'] = $item->id;
         $data['itemFavorite'] = $item->favorite;
     } elseif ($request->get('action') == 'delete') {
         $item = Item::findOrFail($request->get('book-id'));
         if ($item->delete()) {
             $data['sweetalert'] = ['title' => 'το βιβλίο Διεγράφηκε...', 'level' => 'success'];
         }
     }
     return $data;
 }
開發者ID:nicsmyrn,項目名稱:library,代碼行數:27,代碼來源:BooksController.php

示例3: scopePublish

 public function scopePublish()
 {
     Item::findOrFail($this->organizations->first()->pivot->id)->update(['published' => 1]);
 }
開發者ID:nicsmyrn,項目名稱:library,代碼行數:4,代碼來源:Product.php

示例4: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $item = Item::findOrFail($id);
     $data = ['id' => $id];
     foreach (array_keys($this->fields) as $field) {
         $data[$field] = old($field, $item->{$field});
     }
     return view('admin.item.edit', ['data' => $data]);
 }
開發者ID:cdandy,項目名稱:meta-admin,代碼行數:15,代碼來源:ItemController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $list = Item::findOrFail($id);
     $list->delete();
     return redirect()->route('service.index', compact('list'))->withMessage('Service has been Deleted')->withStatus('success');
 }
開發者ID:suchayj,項目名稱:easymanage,代碼行數:12,代碼來源:ServiceController.php

示例6: update

 /**
  *
  * @param Request $request
  * @param Item $item
  * @return Response
  */
 public function update(Request $request, Item $item)
 {
     if ($request->has('updatingNextTimeForRecurringItem')) {
         $item = $this->itemsRepository->updateNextTimeForRecurringItem($item);
     } else {
         $data = array_compare($item->toArray(), $request->only(['priority', 'urgency', 'title', 'body', 'favourite', 'pinned', 'alarm', 'not_before', 'recurring_unit', 'recurring_frequency']));
         //So the recurring unit can be removed
         if ($request->get('recurring_unit') === 'none') {
             $data['recurring_unit'] = null;
         }
         //So the not before time can be removed
         if ($request->exists('not_before') && !$request->get('not_before')) {
             $data['not_before'] = null;
         }
         //So the recurring frequency can be removed
         if ($request->get('recurring_frequency') === '') {
             $data['recurring_frequency'] = null;
         }
         //So the alarm of an item can be removed
         if ($request->has('alarm') && !$request->get('alarm')) {
             $data['alarm'] = null;
         }
         //So the urgency of an item can be removed
         if ($request->has('urgency') && !$request->get('urgency')) {
             $data['urgency'] = null;
         }
         $item->update($data);
         if ($request->has('parent_id')) {
             //So the parent_id can be removed (so the item moves to the top-most level, home)
             if ($request->get('parent_id') === 'none') {
                 $item->parent()->dissociate();
             } else {
                 $item->parent()->associate(Item::findOrFail($request->get('parent_id')));
             }
             $item->save();
         }
         if ($request->has('category_id')) {
             $item->category()->associate(Category::findOrFail($request->get('category_id')));
             $item->save();
         }
         if ($request->has('moveItem')) {
             $this->itemsRepository->moveItem($request, $item);
         }
     }
     $item = $this->transform($this->createItem($item, new ItemTransformer()))['data'];
     return response($item, Response::HTTP_OK);
 }
開發者ID:JennySwift,項目名稱:lists,代碼行數:53,代碼來源:ItemsController.php

示例7: othercode

 public function othercode($id)
 {
     $item = Item::findOrFail($id);
     $items = OtherBarcode::where('item_id', $id)->get();
     return view('item.othercode', compact('item', 'items'));
 }
開發者ID:renciebautista,項目名稱:pcount2,代碼行數:6,代碼來源:ItemController.php


注:本文中的app\models\Item::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。