当前位置: 首页>>代码示例>>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;未经允许,请勿转载。