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


PHP Product::whereIn方法代码示例

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


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

示例1: getCart

 public function getCart()
 {
     $cart_products = Product::whereIn('id', Session::get("pro_ids"))->get();
     $session_price = Session::get("price");
     $plan_duration = Session::get("duration");
     return view('cart', compact('cart_products', 'session_price', 'plan_duration'));
 }
开发者ID:hafizzain,项目名称:mei-project,代码行数:7,代码来源:CartController.php

示例2: treeProducts

 public function treeProducts()
 {
     // Get ids of descendants
     $categories = $this->leaves()->lists('id');
     // Include the id of category itself
     // $categories[] = $categories->getKey();
     // Get Products
     return Product::whereIn('category_id', $categories)->get();
 }
开发者ID:bluecipherz,项目名称:gl-ct,代码行数:9,代码来源:Category.php

示例3: getProductsStatus

 public function getProductsStatus($date)
 {
     $res = new \StdClass();
     $res->lists = [];
     $listIds = [];
     foreach (DB::table('daylist')->join('lists', 'daylist.list', '=', 'lists.id')->where('day', '=', $date)->get() as $l) {
         $list = new \StdClass();
         $list->id = $l->id;
         $listIds[] = $l->id;
         $list->done_products = round(DB::table('products')->select(DB::raw('sum(unitprice*quantity) as product_sum'))->whereNull('deleted_at')->where('list', '=', $l->id)->where('status', 'done')->first()->product_sum);
         $list->all_products = round(DB::table('products')->select(DB::raw('sum(unitprice*quantity) as product_sum'))->whereNull('deleted_at')->where('list', '=', $l->id)->first()->product_sum);
         $list->budget = round($l->budget);
         $res->lists[] = $list;
     }
     $products = Product::whereIn('list', $listIds)->orderBy('status')->orderBy('name')->get();
     $res->statuses = [];
     $res->product_info = [];
     foreach ($products as $product) {
         $res->statuses[$product->status][] = $product->id;
         $p = new \StdClass();
         $p->id = $product->id;
         $p->name = $product->name;
         $p->unitprice = $product->unitprice;
         $p->quantity = $product->quantity;
         $p->moms = $product->moms;
         $res->product_info[] = $p;
     }
     $res->deleted_products = [];
     foreach (DB::table('products')->whereIn('list', $listIds)->whereNotNull('deleted_at')->get() as $p) {
         $res->deleted_products[] = $p->id;
     }
     return response()->json($res);
 }
开发者ID:jonasdahl,项目名称:mammeriet,代码行数:33,代码来源:ShopApiController.php

示例4: index

 public function index()
 {
     $employees = Employee::select('line_id')->where('manager_id', \Auth::user()->id)->get();
     $products = Product::whereIn('line_id', $employees)->get();
     $employees = Employee::select('id')->where('manager_id', \Auth::user()->id)->get();
     $customers = Customer::whereIn('mr_id', $employees)->get();
     $employees = Employee::where('manager_id', \Auth::user()->id)->get();
     $dataView = ['productsCount' => count($products), 'plansCount' => AMPlan::where('month', \Config::get('app.current_month'))->count(), 'reportsCount' => AMReport::where('month', \Config::get('app.current_month'))->count(), 'customersCount' => count($customers), 'employeesCount' => count($employees)];
     return view('am.index', $dataView);
 }
开发者ID:m-gamal,项目名称:crm,代码行数:10,代码来源:DashboardController.php

示例5: index

 public function index(Request $request)
 {
     $q = $request->get('q');
     if ($request->has('cat')) {
         $selected_category = Category::find($request->get('cat'));
         // can't use this to get selected category > child's > product
         // $products = $selected_category->products()->where('name', 'LIKE', '%'.$q.'%')->paginate(4);
         // we use this to get product from current category and its child
         $products = Product::whereIn('id', $selected_category->related_products_id)->where('name', 'LIKE', '%' . $q . '%')->paginate(4);
     } else {
         $products = Product::where('name', 'LIKE', '%' . $q . '%')->paginate(4);
     }
     return view('catalogs.index', compact('products', 'q', 'cat', 'selected_category'));
 }
开发者ID:rawaludin,项目名称:approcket-preproject,代码行数:14,代码来源:CatalogsController.php

示例6: category

 public function category($catename)
 {
     //$categories = Category::with('children')->where('parent_id', '=', 0)->orderBy('did')->get();
     $main_category = Category::with('parent', 'children', 'children.products')->where('category_name', $catename)->firstOrFail();
     if (count($main_category->parent) > 0) {
         $parent_category = Category::with('children')->findOrFail($main_category->parent->id);
     } else {
         $parent_category = null;
     }
     //dd($parent_category);
     $cate_products = Product::where('category_id', $main_category->id)->with(['images', 'prices', 'prices.unit', 'mrps'])->has('images')->has('prices')->orderBy('updated_at', 'desc')->get();
     $sub_categories = Category::with('children')->where('parent_id', $main_category->id)->lists('id');
     $sub_products = Product::whereIn('category_id', $sub_categories)->with('images', 'prices', 'prices.unit', 'mrps', 'mrps.unit')->has('images')->has('prices')->orderBy('updated_at', 'desc')->get();
     //dd($cate_products);
     $page_title = $main_category->category_name . ' - Best ' . $main_category->category_name . ' in Trichy';
     //dd($page_title);
     return view('site/category', compact('categories', 'main_category', 'cate_products', 'parent_category', 'sub_products', 'page_title'));
 }
开发者ID:axicraw,项目名称:tropara,代码行数:18,代码来源:PagesController.php

示例7: saveScore

 public function saveScore(Request $request)
 {
     $stores_ids = $this->user->stores->pluck('id');
     $this->_brands = Brand::join('store_brand as s', 's.bid', '=', 'brands.id')->whereIn('s.sid', $stores_ids)->get(['brands.*']);
     $fids = Product::whereIn('bid', $this->_brands->pluck('id'))->pluck('fid');
     $key = 'bonus_' . $this->user->getKey() . '_game';
     $times = intval(Cache::get($key, 0));
     $save_code_key = 'save_put_code_' . $this->user->getKey();
     $ver_code = $request->get('ver_code');
     if (session($save_code_key) == $ver_code && !empty($fids) && $times > 0) {
         $fids = array_unique((array) $fids);
         //把关注店铺,相关的厂商都加红包
         $score = $request->get('score');
         //分数
         if ($score < 1) {
             $data = ['err_msg' => '红包金额不能为空.'];
             return $this->failure(NULL, false, $data, true);
         }
         $type_id = $request->get('type_id');
         //活动id
         foreach ($fids as $fid) {
             $activity_bouns = new ActivityBonus();
             $activity_bouns->uid = $this->user->getKey();
             $activity_bouns->fid = $fid;
             $activity_bouns->activity_id = with(Activity::where('fid', $fid)->where('type_id', $type_id)->first())->id;
             $activity_bouns->bonus = intval($score) > 98 ? 98 : intval($score);
             $activity_bouns->status = 0;
             $activity_bouns->save();
         }
         Cache::decrement($key);
         session([$save_code_key => '']);
         //红包的个数
         $bonus_cnt = ActivityBonus::where('uid', $this->user->getKey())->where('status', 0)->count();
         $data = ['times' => --$times, 'bonus_cnt' => $bonus_cnt];
         return $this->success(NULL, false, $data);
     } else {
         $data = ['err_msg' => '暂时没添加相关活动。'];
         return $this->failure(NULL, false, $data, true);
     }
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:40,代码来源:GameController.php

示例8: recommend

 public function recommend($curr_page, $pIdArray = array())
 {
     if (count($pIdArray)) {
         $products = Product::whereIn('id', $pIdArray)->get();
     } else {
         $products = Product::all();
     }
     $user = Auth::user();
     foreach ($products as $key => $eachproduct) {
         $eachproduct->img = $eachproduct->imgloc('primary_packaging');
         foreach ($eachproduct->preferences as $eachpreference) {
             if ($eachpreference->user_id == $user->id && $eachpreference->flag == 0) {
                 $pid = $eachproduct->id;
                 unset($products[$key]);
                 continue;
             }
         }
     }
     foreach ($products as $key => $eachproduct) {
         $score = $user->product_distance($eachproduct);
         $eachproduct->score = $score;
         unset($products[$key]['preferences']);
     }
     $sortedProducts = $products->toArray();
     usort($sortedProducts, function ($a, $b) {
         return $b['score'] - $a['score'];
     });
     $next_count = ($curr_page - 1) * 9;
     $paginate['total_pages'] = floor(count($sortedProducts) / 9) + 1;
     $paginate['prev_page'] = $curr_page - 1;
     $paginate['next_page'] = $curr_page + 1;
     if ($paginate['next_page'] > $paginate['total_pages']) {
         $paginate['next_page'] = 0;
     }
     $sortedProducts = array_splice($sortedProducts, $next_count, 9);
     return [$sortedProducts, $paginate];
 }
开发者ID:nyrnzn,项目名称:beautimetreapi,代码行数:37,代码来源:Product.php

示例9: getList

 /**
  * Shows list page.
  *
  * @param $id, the id of the list
  * @return Response, a view for showing a specific list page.
  */
 public function getList($date)
 {
     $res = DB::table('daylist')->where('day', '=', $date)->get();
     $lists = $listIDs = [];
     foreach ($res as $r) {
         $list = ShoppingList::find($r->list);
         $listIDs[] = $r->list;
         $lists[] = $list;
         $list->products()->orderBy('status')->orderBy('name')->get();
     }
     $products = Product::whereIn('list', $listIDs)->orderBy('status')->orderBy('name')->get();
     return view('shop.list')->with('date', $date)->with('lists', $lists)->with('products', $products);
 }
开发者ID:jonasdahl,项目名称:mammeriet,代码行数:19,代码来源:ShopController.php

示例10: getTotalProductsAttribute

 /**
  * Get total amount of product from current category and its child
  * @return int
  */
 public function getTotalProductsAttribute()
 {
     return Product::whereIn('id', $this->related_products_id)->count();
 }
开发者ID:rawaludin,项目名称:approcket-preproject,代码行数:8,代码来源:Category.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $arrProduct = $request->session()->get('Product');
     $arrProductComplete = Product::whereIn('id', $arrProduct)->get();
     return view('orders.index', ['products' => $arrProductComplete]);
 }
开发者ID:luizpcam,项目名称:cartSimulation,代码行数:11,代码来源:OrdersController.php

示例12: news_feed_load_more

 public function news_feed_load_more(Request $request)
 {
     $limit = 40;
     $page = $request->page;
     $class_name = $request->class_name;
     $category_id = $request->category_id;
     if ($class_name != null) {
         $class = DB::select("select * from classes where replace(name,' ','') like ?", [$class_name])[0];
         $usersIdOfThisClass = StudyClass::find($class->id)->registers()->select(DB::raw('user_id'))->get()->pluck('user_id');
         $products = Product::whereIn('author_id', $usersIdOfThisClass)->orderBy('created_at', 'desc')->skip($page * $limit)->take($limit)->get();
     } else {
         if ($category_id != null) {
             $category = CategoryProduct::find($category_id);
             $products = $category->products()->orderBy('created_at', 'desc')->skip($page * $limit)->take($limit)->get();
         } else {
             $type = $request->type;
             if ($type == 3) {
                 $products = Product::orderBy('created_at', 'desc')->where('type', '=', 2)->skip($page * $limit)->take($limit)->get();
             } else {
                 if ($type == 2) {
                     $products = Product::orderBy('rating', 'desc')->skip($page * $limit)->take($limit)->get();
                 } else {
                     //            $class = DB::select("select * from classes where replace(name,' ','') like ?", [$class_name])[0];
                     //            $usersIdOfThisClass = StudyClass::find($class->id)->registers()->select(DB::raw('user_id'))->get()->pluck('user_id');
                     //            $products = Product::whereIn('author_id', $usersIdOfThisClass)->orderBy('created_at', 'desc')->take($limit)->get();
                     $products = Product::orderBy('created_at', 'desc')->skip($page * $limit)->take($limit)->get();
                 }
             }
         }
     }
     $data['user'] = $this->user;
     $data['products'] = $products;
     return view('ajax.newsfeed_load_more', $data);
 }
开发者ID:Kaelcao,项目名称:colormev2,代码行数:34,代码来源:StudentController.php

示例13: getItemsChildeAndSelf

 /**
  * @return mixed
  */
 public function getItemsChildeAndSelf()
 {
     return Product::whereIn('catalog_id', $this->getChildeAndSelf())->active()->sort()->paginate(15);
 }
开发者ID:larabox,项目名称:larabox,代码行数:7,代码来源:Catalog.php

示例14: getProductByCatIds

 public static function getProductByCatIds($catId)
 {
     $catIds = static::getChildCatIds($catId);
     $catIds = array_merge($catIds, (array) (int) $catId);
     $categories = static::whereIn('id', $catIds)->get();
     $arrProduct = [];
     foreach ($categories as $category) {
         foreach ($category->products as $product) {
             $arrProduct[] = $product->id;
         }
     }
     return $products = Product::whereIn('id', $arrProduct)->paginate(PAGINATE_NUM);
 }
开发者ID:laraviet,项目名称:catalog,代码行数:13,代码来源:Category.php

示例15: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, $seo)
 {
     App\Product::where('id', $id)->increment('views');
     $post = App\Blog::where('id', $id)->get()->first();
     return \View::make('post', ['title' => 'Blog', 'favorites' => App\Product::orderBy('views', 'desc')->limit(6)->get(), 'post' => $post, 'relevant' => App\Product::whereIn('section_id', explode(';', $post->sections))->orderBy('views', 'desc')->limit(6)->get()]);
 }
开发者ID:bausano,项目名称:Ebchod,代码行数:12,代码来源:BlogController.php


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