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


PHP Item::with方法代码示例

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


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

示例1: storeComment

 public function storeComment($itemId, Request $request)
 {
     $item = Item::with('comments.user')->findOrFail($itemId);
     $comment = new Comment(['user_id' => $request->userId, 'message' => $request->message]);
     $newComment = $item->comments()->save($comment);
     $result = Comment::with('user')->findOrFail($newComment->id);
     event(new UserPostedAComment($result));
     return $result;
 }
开发者ID:marktimbol,项目名称:sell-used-items,代码行数:9,代码来源:ItemsController.php

示例2: show

 public function show($id)
 {
     $list = Dramalist::find($id);
     $list->load(['user' => function ($query) {
         $query->select('id', 'name');
     }]);
     $items = Item::with(['drama' => function ($query) {
         $query->select('id', 'title', 'type', 'era', 'genre', 'original', 'count', 'state', 'sc', 'poster_url');
     }, 'episode' => function ($query) {
         $query->select('id', 'title', 'alias', 'release_date', 'duration', 'poster_url');
     }])->select('id', 'no', 'drama_id', 'episode_id', 'review', 'created_at', 'updated_at')->where('list_id', $id)->orderBy('no')->paginate(20);
     return view('list.show', ['list' => $list, 'items' => $items]);
 }
开发者ID:suowei,项目名称:saoju,代码行数:13,代码来源:ListController.php

示例3: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $start = microtime(true);
     $collection = Item::with('files')->search($this->argument('term'))->get()->take($this->argument('results'));
     $rows = [];
     foreach ($collection as $item) {
         $path = $item->path;
         $rows[] = ['Item', $item->title, $path];
         foreach ($item->files as $file) {
             $rows[] = ['File', "- {$file->filename}", "{$path}/{$file->filename}"];
         }
     }
     $end = microtime(true);
     $this->table(['type', 'filename', 'path'], $rows);
     $this->line("Took " . round($end - $start, 3) . "s to search");
 }
开发者ID:bagf,项目名称:laravel-file-search,代码行数:21,代码来源:IndexSearch.php

示例4: getEdit

 public function getEdit($id = null)
 {
     $item = \App\Item::with('stores')->find($id);
     //Get data for the item to be edited
     $amounts_for_dropdown = [0, 25, 50, 75, 100];
     $locations_for_dropdown = ['Aisle', 'Bakery', 'Bulk', 'Dairy', 'Meat', 'Produce', 'Seafood', 'Specialty'];
     $storeModel = new \App\Store();
     //Call the model to get an array of all the possible stores with their id
     $stores_for_checkbox = $storeModel->getStoresForCheckboxes();
     $stores_for_this_item = [];
     foreach ($item->stores as $store) {
         //Create an array of store names for this food item
         $stores_for_this_item[] = $store->name;
     }
     return view('items.edit')->with(['item' => $item, 'amounts_for_dropdown' => $amounts_for_dropdown, 'locations_for_dropdown' => $locations_for_dropdown, 'stores_for_checkbox' => $stores_for_checkbox, 'stores_for_this_item' => $stores_for_this_item]);
 }
开发者ID:Matt49,项目名称:grocerylist,代码行数:16,代码来源:ItemController.php

示例5: demo

 public function demo()
 {
     $new_items = Item::with('itemTags', 'itemInto.item', 'itemFrom.item', 'itemMaps')->get();
     return View::make('item.alldemo')->with('items', $new_items);
 }
开发者ID:jakoberzar,项目名称:ItemSenpai,代码行数:5,代码来源:ItemController.php

示例6: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $categories = $this->categories;
     try {
         $item = Item::with('images')->findOrFail($id);
     } catch (ModelNotFoundException $ex) {
         Flash::error('No item found' . $ex);
         return redirect()->route('store.items.index');
     }
     return view('store.items.edit', compact('item', 'categories'));
 }
开发者ID:namoosshah,项目名称:basketball,代码行数:17,代码来源:ItemsController.php


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