當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Product::newQuery方法代碼示例

本文整理匯總了PHP中app\Product::newQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::newQuery方法的具體用法?PHP Product::newQuery怎麽用?PHP Product::newQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Product的用法示例。


在下文中一共展示了Product::newQuery方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request, $id)
 {
     //總銷售金額
     $order = new Order();
     $_data['sell_total_money'] = $order->newQuery()->whereRaw('`status`>?', array(1))->sum('total_money');
     //總訂單數
     $_data['order_total_cnt'] = $order->newQuery()->count();
     //總商品數
     $product = new Product();
     $_data['product_total_cnt'] = $product->newQuery()->count();
     //總用戶數
     $user = new User();
     $_data['user_total_cnt'] = $user->newQuery()->count();
     $this->_week_start = $week_start = date("Y-m-d 00:00:00", strtotime("-" . (date("w") - 1) . " days"));
     //本周銷售
     $_data['sell_week_money'] = $order->newQuery()->whereRaw('created_at>= ? and `status`>?', array($week_start, 1))->sum('total_money');
     //本周訂單
     $_data['order_week_cnt'] = $order->newQuery()->whereRaw('created_at>= ?', array($week_start))->count();
     //本周商品
     $_data['product_week_cnt'] = $product->newQuery()->whereRaw('created_at>= ?', array($week_start))->count();
     //本周用戶
     $_data['user_week_cnt'] = $user->newQuery()->whereRaw('created_at>= ?', array($week_start))->count();
     $this->_data = $_data;
     return $this->view('admin.dashboard');
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:30,代碼來源:HomeController.php

示例2: special

 public function special(Request $request, $activity_id = 0)
 {
     $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.*']);
     $pagesize = $request->input('pagesize') ?: $this->site['pagesize']['m'];
     $this->_input = $request->all();
     $product = new Product();
     //查找猴子撈月所有在線,有效活動id
     $now = date("Y-m-d H:i:s");
     if (!empty($activity_id)) {
         $activity = Activity::find($activity_id);
     } elseif (!empty($request->get('type_id'))) {
         $fids = $product->newQuery()->whereIn('bid', $this->_brands->pluck('id'))->pluck('fid');
         if (!empty($fids)) {
             $fids = array_unique((array) $fids);
         }
         $builder = Activity::whereIn('fid', $fids)->where('type_id', $request->get('type_id'));
         $activity = $builder->first();
         $activity_id = $builder->pluck('id');
     } else {
         return $this->failure(NULL);
     }
     if (empty($activity)) {
         return $this->failure('activity::activity.no_activity');
     } elseif ($activity->start_date > $now || $activity->end_date < $now || $activity->status != 1) {
         return $this->failure('activity::activity.failure_activity');
     }
     //查看當前以以和店鋪 猴子撈月 活動所有商品
     $builder = $product->newQuery()->with(['sizes', 'covers']);
     $this->_activity = $activity;
     $this->_table_data = $builder->whereIn('activity_type', (array) $activity_id)->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize);
     return $this->view('activity::m.special');
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:33,代碼來源:ActivityController.php

示例3: classify

 public function classify(Request $request)
 {
     $search_key = $request->input('search_key');
     $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.*']);
     $pagesize = $request->input('pagesize') ?: $this->site['pagesize']['m'];
     $this->_input = $request->all();
     $product = new Product();
     $builder = $product->newQuery()->with(['sizes', 'covers']);
     if (!empty($search_key)) {
         $builder->where('title', 'like', '%' . $search_key . '%');
     }
     $this->_search_key = $search_key;
     $this->_table_data = $builder->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize);
     return $this->view('m.classify');
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:16,代碼來源:SearchController.php

示例4: export

 public function export(Request $request)
 {
     $product = new Product();
     $builder = $product->newQuery()->with('brand');
     $page = $request->input('page') ?: 0;
     $pagesize = $request->input('pagesize') ?: config('site.pagesize.export', 1000);
     $total = $this->_getCount($request, $builder);
     if (empty($page)) {
         $this->_of = $request->input('of');
         $this->_table = $product->getTable();
         $this->_total = $total;
         $this->_pagesize = $pagesize > $total ? $total : $pagesize;
         return $this->view('admin.product.export');
     }
     $data = $this->_getExport($request, $builder);
     return $this->success('', FALSE, $data);
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:17,代碼來源:ProductController.php


注:本文中的app\Product::newQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。