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


PHP Product::query方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $query = Product::query()->with('module');
     if (Input::query('keyword')) {
         $query->where('name', 'like', '%' . Input::query('keyword') . '%');
     }
     $page = Input::query('page') ? Input::query('page') : 1;
     $per_page = Input::query('per_page') ? Input::query('per_page') : false;
     $list_total = $query->count();
     if ($per_page) {
         $query->skip(($page - 1) * $per_page)->take($per_page);
         $list_start = ($page - 1) * $per_page + 1;
         $list_end = ($page - 1) * $per_page + $per_page;
         if ($list_end > $list_total) {
             $list_end = $list_total;
         }
     } else {
         $list_start = 1;
         $list_end = $list_total;
     }
     $results = $query->get();
     return response($results)->header('Items-Total', $list_total)->header('Items-Start', $list_start)->header('Items-End', $list_end);
 }
开发者ID:uicestone,项目名称:SmartBuild,代码行数:28,代码来源:ProductController.php

示例2: ajaxSearch

 /** Ajax поиск по каталогу
  * @param array $params
  * @return Builder
  */
 private function ajaxSearch(array $params, Category $category = null)
 {
     is_null($category) ? $products = Product::query() : ($products = Product::query()->byCategory($category));
     if (array_key_exists('season', $params)) {
         $products = $products->bySeason($params['season']);
     }
     if (array_key_exists('new', $params)) {
         $products = $products->new();
     }
     return $products;
 }
开发者ID:yurilabatsevich,项目名称:test.dev,代码行数:15,代码来源:CatalogController.php

示例3: product_search

 public function product_search(Request $request)
 {
     $this->setMetadata('Tìm kiếm tin đăng');
     $product_type_id = $request->input('product_type');
     $province_id = $request->input('province');
     $district_id = $request->input('district');
     $ward_id = $request->input('ward');
     $street_id = $request->input('street');
     $price_range_id = $request->input('price');
     $area_range_id = $request->input('area');
     $incense_type_id = $request->input('incense');
     $limit = Config::findByKey('rows_per_page_product')->first()->value;
     $searchDescription = "";
     $product_type = null;
     $province = null;
     $district = null;
     $ward = null;
     $street = null;
     $query = Product::query();
     try {
         if (isset($product_type_id) && $product_type_id != "") {
             $query->where('product_type_id', $product_type_id);
             $product_type = product_type::findOrFail($product_type_id);
             $searchDescription .= $product_type->name;
         }
         if (isset($province_id) && $province_id != "") {
             $query->where('province_id', $province_id);
             $province = Province::findOrFail($province_id);
             $searchDescription .= ", " . $province->name;
         }
         if (isset($district_id) && $district_id != "") {
             $query->where('district_id', $district_id);
             $district = District::findOrFail($district_id);
             $searchDescription .= ", " . $district->name;
         }
         if (isset($ward_id) && $ward_id != "") {
             $query->where('ward_id', $ward_id);
             $ward = Ward::findOrFail($ward_id);
             $searchDescription .= ", " . $ward->name;
         }
         if (isset($street_id) && $street_id != "") {
             $query->where('street_id', $street_id);
             $street = Street::findOrFail($street_id);
             $searchDescription .= ", " . $street->name;
         }
     } catch (Exception $e) {
     }
     $products = $query->paginate($limit);
     $product_types = Product_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
     $hcmProvince = Province::findByKey('ho-chi-minh')->first();
     // dd($hcmProvince->id);
     $districtProduct = District::where('province_id', '=', $hcmProvince->id)->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
     return view('frontend.sites1.product_search', ['products' => $products, 'product_types' => $product_types, 'districtProduct' => $districtProduct, 'searchDescription' => $searchDescription]);
 }
开发者ID:vankhoektcn,项目名称:Qqsipe2UY67gLO7BWrou,代码行数:54,代码来源:SiteControllers.php

示例4: category

 public function category($cat)
 {
     if ($cat == 'sales') {
         $productArray = \App\Product::where('sale', 1)->get();
     } else {
         $productArray = \App\Product::where('category', $cat)->get();
     }
     $games = new GiantBombApi();
     $gameInfo = $games->getAllGameInfoById(34402);
     $productimg = Product::query()->orderByRaw("RAND()")->limit(5)->get();
     $product_sale_img = Product::query()->where('sale', 1)->get();
     return view('shop.index', compact('gameInfo', 'productArray', 'productimg', 'product_sale_img'));
 }
开发者ID:akuo95,项目名称:Project-Vlambeer,代码行数:13,代码来源:ProductsController.php


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