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


PHP Product::getProducts方法代码示例

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


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

示例1: buildIndex

 /**
  * @param bool $type
  * @param bool $type_id
  * @param bool $chain
  * @param bool $strSearch
  * @return $this
  */
 public function buildIndex($type = false, $type_id = false, $chain = false, $strSearch = false)
 {
     //pr($this->_glob['_curr']);
     $productModel = new Product();
     $purchaseModel = new Purchase();
     $categoryModel = new Category();
     $brandModel = new Brand();
     $labelModel = new Label();
     $userModel = new User();
     //$categoryModel = new Category();
     //$brandModel = new Brand();
     $count = $this->_glob['_countProductsOfPage'];
     //количество товаров на странице по умолчанию
     if (isset($_GET['show']) and $_GET['show'] == 'all') {
         $count = $this->_glob['_maxCountProductsOfPage'];
     }
     $products = $productModel->getProducts($type, $type_id, $count, $strSearch);
     //получаем товары
     /*pr($products,true);
       return view('welcome');*/
     $productsIds = $products->pluck('id');
     $productsIds = $productsIds->toArray();
     $terms = $purchaseModel->getVendorTerms($productsIds);
     //получаем условия поставщиков по выбранным товарам
     $labels = $labelModel->getLabelsByProductsId($productsIds);
     foreach ($products as &$product) {
         //pr($product);
         if (count($terms) > 0) {
             $arTerms = [];
             //$terms = $terms->sortBy('base_price');
             $terms = $terms->sortBy('sort');
             /*pr($terms);*/
             $i = 1;
             foreach ($terms as $term) {
                 if ($product->id == $term->product_id) {
                     $term->zakup = toFloat($term->base_price * ((100 - $term->discount_price) / 100) * ($this->_glob['_curr'][$term->currency]['RATE'] * (1 + $term->raise / 100)) * ((100 - $term->discount_bulk) / 100));
                     //та самая ебанутая формула расчета закупа
                     $arTerms[] = $term;
                     if ($i == 3) {
                         break;
                     }
                     $i++;
                 }
             }
             $product->terms = $arTerms;
         }
         if (count($labels) > 0) {
             $arLabel = [];
             foreach ($labels as $label) {
                 if ($product->id == $label->product_id) {
                     $arLabel[] = $label;
                 }
             }
             $product->labels = $arLabel;
         }
     }
     //pr($products);
     $categories_list = $categoryModel->getFullCategoriesList();
     $brands_list = $brandModel->getFullBrandsList();
     $userTemplates = $userModel->getTemplates('products');
     $serializeFields = $userModel->getFields(Auth::User()->template_prod_id, 'products');
     $showFields = false;
     if ($serializeFields != null) {
         $showFields = unserialize($serializeFields->fields);
     }
     $pathToPurchase = '/purchase';
     if ($type == 'category') {
         $pathToPurchase = '/purchase/category/' . $type_id[0];
     }
     if ($type == 'brand') {
         $pathToPurchase = '/purchase/brand/' . $type_id;
     }
     if ($type == 'product') {
         $pathToPurchase = '/purchase/product/' . $type_id;
     }
     if ($type == 'label') {
         $pathToPurchase = '/purchase/label/' . $type_id;
     }
     if ($type == 'flag') {
         $pathToPurchase = '/purchase/flag/';
     }
     if ($strSearch) {
         $pathToPurchase = '/purchase/search/' . $strSearch;
     }
     return view('products.index')->with('title', 'Товары')->with('products', $products)->with('chain', $chain)->with('categories_list', $categories_list)->with('brands_list', $brands_list)->with('pathToPurchase', $pathToPurchase)->with('templates', $userTemplates)->with('fields', $showFields);
 }
开发者ID:enotsokolov,项目名称:vp_plus,代码行数:93,代码来源:ProductController.php

示例2: api

 public function api()
 {
     return response()->json(Product::getProducts());
 }
开发者ID:raylight75,项目名称:cms,代码行数:4,代码来源:ApiController.php


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