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


PHP Category::with方法代码示例

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


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

示例1: getProductsOrderedByCategory

 /**
  * Return the categories with their products
  *
  * @return mixed
  */
 public function getProductsOrderedByCategory()
 {
     return Category::with(['products' => function ($q) {
         $q->select(['products.id', 'category_id', 'name', 'price', 'visible', 'sort', 'category_id_sub']);
         $q->orderBy('sort');
     }])->orderBy('sort')->get();
 }
开发者ID:FomKiosk,项目名称:API-Laravel,代码行数:12,代码来源:ProductRepository.php

示例2: getCategoriesWithProducts

 public function getCategoriesWithProducts()
 {
     $categories = Category::with('products')->get();
     if ($categories->isEmpty()) {
         return $this->responseNotFound(['Categories is empty']);
     }
     return $this->responseOk($categories);
 }
开发者ID:restoko,项目名称:restoko-api,代码行数:8,代码来源:CategoriesController.php

示例3: get

 public function get($month, $year)
 {
     $this->month = $month;
     $this->year = $year;
     return Category::with(array('items' => function ($q) {
         $q->where(DB::raw('MONTH(items.created_at)'), '=', $this->month)->where(DB::raw('YEAR(items.created_at)'), '=', $this->year);
     }))->get();
 }
开发者ID:nq2916,项目名称:savings,代码行数:8,代码来源:Item.php

示例4: get_categories

 private function get_categories()
 {
     $categories = Cache::rememberForever('wechat_index_categories_wfh', function () {
         $categories = Category::with('children')->where('parent_id', '0')->orderBy('parent_id', 'asc')->orderBy('sort_order', 'asc')->orderBy('id', 'asc')->get();
         return $categories;
     });
     return $categories;
 }
开发者ID:noikiy,项目名称:wfhshop_wechat_laravel,代码行数:8,代码来源:IndexController.php

示例5: get_categories

 private function get_categories()
 {
     $categories = Cache::rememberForever('wyshop_admin_category_categories', function () {
         $categories = Category::with('goods')->orderBy('parent_id', 'asc')->orderBy('sort_order', 'asc')->orderBy('id', 'asc')->get();
         return tree($categories);
     });
     return $categories;
 }
开发者ID:beidouzhiguang,项目名称:wy_shop,代码行数:8,代码来源:CategoryController.php

示例6: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $categories = Category::with('translations')->get();
     $amenities = Tag::with('translations')->get();
     return view('dashboard.spaces.create', compact('categories', 'amenities'));
 }
开发者ID:optimatec,项目名称:cowork,代码行数:11,代码来源:SpaceController.php

示例7: 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, ['title' => 'required|min:3', 'description' => 'min:3']);
     $category = Category::find($id);
     $old_title = $category->title;
     if ($category) {
         \DB::transaction(function () use($request, $category) {
             $category->translate()->title = $request->get('title');
             $category->translate()->description = $request->get('description');
             $category->parent_id = $request->get('parent_id');
             return $category->save();
         });
     }
     session()->flash('message', ['success', "Your category has been updated from <strong><i>" . $old_title . "</i></strong> to <strong><i>" . $category->title . "</i></strong>, successfully!"]);
     $categories = Category::with('translations')->paginate(10);
     return view('dashboard.categories.index', compact('categories'));
 }
开发者ID:optimatec,项目名称:cowork,代码行数:25,代码来源:CategoryController.php

示例8: getDataViewComponent

 public function getDataViewComponent($categoryID)
 {
     $category = Category::with('accessories.company')->find($categoryID);
     $category_assets = $category->components;
     if (Input::has('search')) {
         $category_assets = $category_assets->TextSearch(e(Input::get('search')));
     }
     if (Input::has('offset')) {
         $offset = e(Input::get('offset'));
     } else {
         $offset = 0;
     }
     if (Input::has('limit')) {
         $limit = e(Input::get('limit'));
     } else {
         $limit = 50;
     }
     $order = Input::get('order') === 'asc' ? 'asc' : 'desc';
     $allowed_columns = ['id', 'name', 'serial', 'asset_tag'];
     $sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
     $count = $category_assets->count();
     $rows = array();
     foreach ($category_assets as $asset) {
         $actions = '';
         $inout = '';
         if ($asset->deleted_at == '') {
             $actions = '<div style=" white-space: nowrap;"><a href="' . route('update/component', $asset->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/component', $asset->id) . '" data-content="' . trans('admin/hardware/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($asset->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
         }
         $rows[] = array('id' => $asset->id, 'name' => (string) link_to_route('view/accessory', $asset->name, [$asset->id]), 'actions' => $actions, 'companyName' => Company::getName($asset));
     }
     $data = array('total' => $count, 'rows' => $rows);
     return $data;
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:33,代码来源:CategoriesController.php

示例9: viewTrash

 public function viewTrash()
 {
     $data = Category::with('subcategories')->onlyTrashed()->get();
     return \Response::json($data);
 }
开发者ID:sujithma,项目名称:AccountsTransaction,代码行数:5,代码来源:CategoryController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $getAllCategories = Category::with('subCatLevel1')->get();
     //dd($getAllCategories);
     return view('categorylist')->with(array('allCategories' => $getAllCategories));
 }
开发者ID:khakanali,项目名称:OpenMAll,代码行数:11,代码来源:CategoryController.php

示例11: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $venue = Venue::where('id', $id)->first();
     $categories = Category::with('translations')->get();
     $amenities = Tag::with('translations')->get();
     return view('dashboard.venues.edit', compact('venue', 'categories', 'amenities'));
 }
开发者ID:optimatec,项目名称:cowork,代码行数:14,代码来源:VenueController.php

示例12: getPriceListInCurrentCategory

 public function getPriceListInCurrentCategory(ProductCart $productCart, $categoryName, $depoId)
 {
     $category = Category::with('product.price.stantion.train_road')->where('category', $categoryName)->first();
     $stantion = Stantion::where('id', $depoId)->first();
     $depoName = $stantion->stantion_name;
     $productsArr = [];
     if (Auth::guest()) {
         $userID = 0;
     } else {
         $userID = Auth::user()->id;
     }
     foreach ($category->product as $product) {
         foreach ($product->price as $price) {
             if ($price->price > 0 && $price->amount > 0) {
                 $productsArr[$price->stantion[0]->train_road->tr_name][$price->stantion[0]->stantion_name][] = ['name' => $product->name, 'product_id' => $product->id, 'depo_id' => $price->stantion[0]->id, 'price_id' => $price->id, 'article' => $product->article, 'description' => $product->description, 'price' => $price->price, 'amount' => $price->amount];
             }
         }
     }
     $sumAndCount = $this->getGeneralViewOfCart($productCart);
     return view('purchases.trainCarPriceListInCurrentCategory', ['p' => 'purchases', 'productsArr' => $productsArr, 'category' => $categoryName, 'userID' => $userID, 'productsCount' => $sumAndCount['productsCount'], 'productsSum' => $sumAndCount['productsSum'], 'whatDepoIdWeAre' => $depoId, 'whatDepoNameWeAre' => $depoName]);
 }
开发者ID:kostik34,项目名称:trains.shop,代码行数:21,代码来源:PurchasesController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $categories = Category::with('user')->get();
     return view('admin.categories.index', compact('categories'));
 }
开发者ID:tavo1987,项目名称:linkbox,代码行数:10,代码来源:CategoryController.php


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