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


PHP Product::select方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $prod = Product::select('products.*', 'pgroups.name AS product_group', 'total_qty')->leftJoin('inventory_totals', 'inventory_totals.product_id', '=', 'products.id')->join('pgroups', 'pgroups.id', '=', 'pgroup_id')->where('products.is_active', 1)->get();
     $products = json_encode($prod);
     $pgroups = DB::table('pgroups')->lists('name', 'id');
     return view('products/index', compact('products', 'pgroups'));
 }
开发者ID:sethathay,项目名称:PPBakery,代码行数:12,代码来源:ProductsController.php

示例2: filterByCategory

 /**
  * Filter products by category
  *
  * @param $request
  * @return Response
  */
 public function filterByCategory(Request $request)
 {
     $title = 'Product Listing';
     $categories = Category::lists('title', 'id')->toArray();
     $products = Product::select(DB::raw("products.id, products.name, products.photo"))->leftJoin('category_product', 'category_product.product_id', '=', 'products.id')->whereIn('category_product.category_id', $request->input('category_id'))->groupBy('product_id')->paginate(10);
     return view('home', compact('title', 'categories', 'products'));
 }
开发者ID:git-mahfuz,项目名称:web-catalog,代码行数:13,代码来源:HomeController.php

示例3: getProductPrice

 public function getProductPrice(Request $request)
 {
     $product_id = $request->get('product_id');
     $price = Product::select("price")->whereId($product_id)->first();
     echo $price->price;
     exit;
 }
开发者ID:sethathay,项目名称:PPBakery,代码行数:7,代码来源:PricingRulesController.php

示例4: detail

 public static function detail($id)
 {
     return Product::select(array(DB::raw("check_coupon(pro_product.id,pro_product.cid_cate,1) AS discountcoupon"), DB::raw("check_coupon(pro_product.id,pro_product.cid_cate,2) AS coupons"), DB::raw("get_review(pro_product.id,1) AS rating"), DB::raw("get_review(pro_product.id,2) AS countrating"), DB::raw("get_price(pro_supplier_product.id,pro_supplier_product.discount) AS discount"), DB::raw("get_sale_price(pro_supplier_product.id,pro_supplier_product.saleprice) AS saleprice"), "pro_product.id AS myid", "pro_product.code", "pro_product.sap_code", "pro_product.is_hot", "pro_product.name", "pro_product.cid_series", "pro_product.cid_cate", "pro_supplier_product.id AS cid_res", "pro_product.isprice", "pro_supplier_product.stock_num", "pro_product.is_sample", "pro_product.is_shopping", "pro_supplier_product.is_tranc", "pro_supplier_product.content", "m.name AS name_supplier", "pro_supplier_product.id AS cid_res", "pro_supplier_product.cid_supplier"))->whereRaw("pro_product.id={$id}  AND pro_supplier_product.status='1' AND pro_product.status='1' AND pro_product.is_status_cate='1' AND pro_product.is_status_series='1' ")->join("pro_supplier_product", function ($join) {
         $join->on("pro_product.id", "=", "pro_supplier_product.cid_product");
     })->join("market_supplier AS m", function ($join) {
         $join->on("m.id", "=", "pro_supplier_product.cid_supplier");
     })->orderBy("pro_supplier_product.date_mod", "DESC")->remember(10)->first();
 }
开发者ID:buitantin,项目名称:mobidmcl,代码行数:8,代码来源:Product.php

示例5: createTags

 private function createTags()
 {
     $product = Product::select(['id', 'name'])->get();
     foreach ($product as $value) {
         $prod = Product::find($value->id);
         $prod->tags = str_replace(' ', ',', $value->name);
         $prod->save();
     }
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:9,代码来源:HomeController.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $users = User::select('id')->get();
     $products = Product::select('id')->get();
     $categories = Category::select('id')->get();
     $areas = Area::select('id')->get();
     $orders = Order::select('id')->get();
     return view('admin.dashboard', compact('users', 'products', 'categories', 'areas', 'orders'));
 }
开发者ID:axicraw,项目名称:tropara,代码行数:15,代码来源:ApanelController.php

示例7: searchByNameAutocomplete

 /**
  * Provides a json encoded array of matching product names
  * @param  string $query
  * @return json
  */
 public static function searchByNameAutocomplete($query, $customer_id = NULL)
 {
     $products = Product::select('*', 'products.name as product_name', 'taxes.name as tax_name')->leftjoin('taxes', 'taxes.id', '=', 'products.tax_id')->orderBy('products.name')->where('products.name', 'like', '%' . $query . '%')->get();
     /*
     $return = array();
     
     foreach ($products as $product)
     {
         // $return[]['value'] = $client->name_fiscal;
         $return[] = array ('value' => $client->name_fiscal, 'data' => $client->id);
     }
     
     return json_encode( array('query' => $query, 'suggestions' => $return) );
     */
     // return json_encode( $products );
     return json_encode(array('query' => $query, 'suggestions' => $products));
 }
开发者ID:rogerapras,项目名称:aBillander,代码行数:22,代码来源:Product.php

示例8: run

 public function run()
 {
     $faker = Faker::create();
     $addresses = Address::get();
     $status_list = array_keys(trans('globals.order_status'));
     $products = Product::select('id', 'price')->get();
     for ($i = 0; $i < 20; $i++) {
         $address = $addresses->random(1);
         $type = $faker->randomElement(['cart', 'wishlist', 'order']);
         $status = 'open';
         switch ($type) {
             case 'order':
                 $status = $faker->randomElement($status_list);
                 break;
         }
         $stock = $faker->numberBetween(1, 20);
         $order = Order::create(['user_id' => $address->user_id, 'seller_id' => '3', 'address_id' => $address->id, 'status' => $status, 'type' => $type, 'description' => $type == 'wishlist' ? $faker->companySuffix : '', 'end_date' => $status == 'closed' || $status == 'cancelled' ? $faker->dateTime() : null]);
         $num = $faker->numberBetween(2, 5);
         $list = [];
         if ($num > 1 && count($products) - 1 < $num) {
             $num = count($products) - 1;
         }
         for ($j = 0; $j < $num; $j++) {
             do {
                 $a = true;
                 $product = $products->random(1);
                 if (in_array($product->id, $list)) {
                     $a = false;
                 } else {
                     $list[] = $product->id;
                 }
             } while ($a == false);
             if ($status == 'closed') {
                 $delivery = $faker->dateTime();
             } else {
                 $delivery = $faker->numberBetween(0, 1) ? $faker->dateTime() : null;
             }
             OrderDetail::create(['order_id' => $order->id, 'product_id' => $product->id, 'price' => $product->price, 'quantity' => $stock, 'delivery_date' => $delivery]);
         }
         $order->sendNotice();
     }
 }
开发者ID:ant-vel,项目名称:antVel,代码行数:42,代码来源:OrdersTableSeeder.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $group_id = false;
     $id = explode('_', $id);
     $view = $id[1];
     $id = $id[0];
     $deleteAll = $view == $id;
     $product = Product::select('id', 'products_group')->with(['group' => function ($query) {
         $query->select('id', 'products_group');
     }])->find($id);
     #is necesary re make the actual group before add to new one because is the principal product of the last one
     if ($product->products_group == $id && count($product->group) > 1) {
         $newPrincipal = Product::select('id')->where('products_group', $id)->where('id', '<>', $id)->first();
         $group_id = $newPrincipal->id;
         Product::where('products_group', $id)->update(['products_group' => $group_id]);
     }
     $product->products_group = null;
     $product->save();
     return json_encode(['deleteAll' => $deleteAll ? true : false, 'message' => trans('product.product_was_deleted_from_this_group')]);
 }
开发者ID:rolka,项目名称:antVel,代码行数:26,代码来源:ProductsGroupController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $products = Product::select()->with('category', 'media', 'tags')->orderBy('publish_date', 'DESC')->get();
     return view('admin.dashboard', compact('products'));
 }
开发者ID:julesnicolas,项目名称:StarWarsShop,代码行数:10,代码来源:ProductsController.php

示例11: getTopRated

 /**
  * This method is able to return the higher rate product list, everything will depends of $point parameter.
  *
  * @param [integer] $point [it is the rate evaluates point, which allows get the products list required]
  * @param [integer] $limit [num of records to be returned]
  * @param [boolean] $tags  [it sees if we want to return a product list or a product tags list]
  *
  * @return [array or laravel collection] $_tags, $products [returning either products tags array or products collection]
  */
 public static function getTopRated($point = '5', $limit = 5, $tags = false)
 {
     if ($tags == true) {
         $products = Product::select(['id', 'tags', 'rate_count', 'rate_val'])->WhereNotNull('tags')->free()->orderBy('rate_count', 'desc')->orderBy('rate_val', 'desc')->take($limit)->get();
         $_tags = [];
         $products->each(function ($prod) use(&$_tags) {
             $array = explode(',', $prod->tags);
             foreach ($array as $value) {
                 if (trim($value) != '') {
                     $_tags[] = trim($value);
                 }
             }
         });
         return array_unique($_tags, SORT_STRING);
     } else {
         $products = Product::select(['id', 'name', 'description', 'features', 'price', 'type', 'stock'])->free()->orderBy('rate_count', 'desc')->orderBy('rate_val', 'desc')->take($limit)->get();
         return $products;
     }
 }
开发者ID:softsolution,项目名称:antVel,代码行数:28,代码来源:ProductsController.php

示例12: search

 /**
  * 根据关键字搜索商品
  *
  * @param $keywords
  * @return response
  */
 public function search($keywords)
 {
     return Product::select('id', 'name')->where('name', 'like', '%' . $keywords . '%')->orderBy('created_at', 'desc')->paginate(10)->toJson();
 }
开发者ID:supermason,项目名称:homestreward,代码行数:10,代码来源:InventoryController.php

示例13: editKey

 /**
  *	edit the number of key registered for email.
  *
  *	@param 	string|int 	id product
  *	@param 	Request 	object to validate the type of request|action to ejecute
  *
  *	@return json
  */
 public function editKey($id, Request $request)
 {
     if (!$request->wantsJson()) {
         return ['message' => trans('globals.error_not_available')];
     }
     if (!$request->has('email')) {
         return ['message' => trans('globals.error_not_available')];
     }
     $cart = Order::ofType('cart')->select('id', 'status')->where('user_id', \Auth::id())->first();
     if (!$cart) {
         return ['message' => trans('globals.error_not_available')];
     }
     $product = Product::select('id', 'stock')->find($id);
     if (!$product) {
         return ['message' => trans('globals.error_not_available')];
     }
     $order = OrderDetail::where('order_id', $cart->id)->where('product_id', $product->id)->first();
     if (!$order) {
         return ['message' => trans('globals.error_not_available')];
     }
     $virtual = VirtualProduct::select('id')->where('product_id', $product->id)->first();
     if ($request->has('delete')) {
         $virtualOrder = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->delete();
         $num2 = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('status', 1)->get()->toArray();
         if (!count($num2)) {
             $order->delete();
         } else {
             $order->quantity = count($num2);
             $order->save();
         }
         return ['all' => true];
     } elseif ($request->has('decrement')) {
         $virtualOrder = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->where('status', 1)->first();
         $virtualOrder->delete();
         $num2 = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('status', 1)->get()->toArray();
         if (!count($num2)) {
             $order->delete();
         } else {
             $order->quantity = count($num2);
             $order->save();
         }
         $num = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->where('status', 1)->get()->toArray();
         if (count($num)) {
             return ['delete' => true, 'num' => count($num)];
         }
         return ['all' => true];
     } elseif ($request->has('increment')) {
         $num2 = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('status', 1)->get()->toArray();
         if (count($num2) + 1 > $product->stock) {
             return ['message' => trans('product.virtualProductOrdersController_controller.no_stock')];
         }
         $virtualOrder = new VirtualProductOrder();
         $virtualOrder->order_id = $order->order_id;
         $virtualOrder->status = 1;
         $virtualOrder->email = $request->input('email');
         $virtualOrder->virtual_product_id = $virtual->id;
         $virtualOrder->save();
         $order->quantity = count($num2) + 1;
         $order->save();
         $num = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->where('status', 1)->get()->toArray();
         return ['insert' => true, 'num' => count($num)];
     }
     return ['message' => trans('globals.error_not_available')];
 }
开发者ID:softsolution,项目名称:antVel,代码行数:72,代码来源:VirtualProductOrdersController.php

示例14: currentStock

 public function currentStock()
 {
     $productStock = Product::select('id', 'name', 'current_stock');
 }
开发者ID:breenyoung,项目名称:wfadmin,代码行数:4,代码来源:ReportController.php

示例15: searchInventory

 public function searchInventory()
 {
     $date = Input::get('date');
     $qty = Input::get('qty');
     if ($qty == 1) {
         $inventory = Product::select('products.id AS product_id', 'products.name', 'products.code', 'pgroups.name AS product_group', 'total_qty')->leftJoin('inventory_totals', 'inventory_totals.product_id', '=', 'products.id')->join('pgroups', 'pgroups.id', '=', 'pgroup_id')->where('products.is_active', 1)->where('products.is_stock', 1)->where('total_qty', '>', 0)->orderBy('pgroups.name', 'ASC')->orderBy('products.name', 'ASC')->get();
     } else {
         if ($qty <= 0 && $qty != "") {
             $inventory = Product::select('products.id AS product_id', 'products.name', 'products.code', 'pgroups.name AS product_group', 'total_qty')->leftJoin('inventory_totals', 'inventory_totals.product_id', '=', 'products.id')->join('pgroups', 'pgroups.id', '=', 'pgroup_id')->where('products.is_active', 1)->where('products.is_stock', 1)->where(function ($query) {
                 $query->where('total_qty', '<', 0)->orWhere('total_qty', null);
             })->orderBy('pgroups.name', 'ASC')->orderBy('products.name', 'ASC')->get();
         } else {
             $inventory = Product::select('products.id AS product_id', 'products.name', 'products.code', 'pgroups.name AS product_group', 'total_qty')->leftJoin('inventory_totals', 'inventory_totals.product_id', '=', 'products.id')->join('pgroups', 'pgroups.id', '=', 'pgroup_id')->where('products.is_active', 1)->where('products.is_stock', 1)->orderBy('pgroups.name', 'ASC')->orderBy('products.name', 'ASC')->get();
         }
     }
     return Response::json($inventory);
 }
开发者ID:sethathay,项目名称:PPBakery,代码行数:17,代码来源:InventoriesController.php


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