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


PHP Product::sellable方法代码示例

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


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

示例1: recommended

 /**
  * Display recommended product by customer
  *
  * 1. Product has viewed/purchased category/tag
  * 2. Product has size of purchased item
  * @return Response
  */
 public function recommended($user_id = 0)
 {
     //1. Check tag/category viewed
     $stat = \App\Models\StatUserView::userid($user_id)->statabletype(['App\\Models\\Category', 'App\\Models\\Tag'])->get(['statable_id'])->toArray();
     //1b. Get slugs
     $slugs = [];
     $purchased_prods = [];
     $purchased_varians = [];
     foreach ($stat as $key => $value) {
         $slugs[] = \App\Models\Cluster::find($value['statable_id'])['slug'];
     }
     $purchased = \App\Models\TransactionDetail::TransactionSellOn(['paid', 'packed', 'shipping', 'delivered'])->where('transactions.user_id', $user_id)->groupby('varian_id')->with(['varian', 'varian.product', 'varian.product.clusters'])->get()->toArray();
     foreach ($purchased as $key => $value) {
         //2. Check tag/category purchased
         foreach ($value['varian']['product']['clusters'] as $key2 => $value2) {
             $slugs[] = $value2['slug'];
         }
         $purchased_prods[] = $value['varian']['product_id'];
         $purchased_varians[] = $value['varian']['size'];
     }
     //2a. get slug of category/tag
     //2b. get product id
     //2c. get varian size
     $slug = array_unique($slugs);
     $productids = array_unique($purchased_prods);
     $variansize = array_unique($purchased_varians);
     $result = \App\Models\Product::sellable(true);
     if (!empty($slug)) {
         $result = $result->clustersslug($slug);
     }
     if (!empty($productids)) {
         $result = $result->notid($productids);
     }
     if (!empty($variansize)) {
         $result = $result->variansize($variansize);
     }
     $count = count($result->get());
     if (Input::has('skip')) {
         $skip = Input::get('skip');
         $result = $result->skip($skip);
     }
     if (Input::has('take')) {
         $take = Input::get('take');
         $result = $result->take($take);
     }
     $result = $result->with(['varians'])->get()->toArray();
     return new JSend('success', (array) ['count' => $count, 'data' => $result]);
 }
开发者ID:ThunderID,项目名称:SHOP-API,代码行数:55,代码来源:MyProductController.php

示例2: pointexpire

 /**
  * update 1st version
  *
  * @return void
  * @author 
  **/
 public function pointexpire($id)
 {
     $queue = new Queue();
     $pending = $queue->find($id);
     $parameters = json_decode($pending->parameter, true);
     $messages = json_decode($pending->message, true);
     $errors = new MessageBag();
     //check point expire on that day that havent get cut by transaction (or even left over)
     $points = PointLog::debit(true)->onactive([Carbon::parse($parameters['on'])->startOfDay()->format('Y-m-d H:i:s'), Carbon::parse($parameters['on'])->endOfDay()->format('Y-m-d H:i:s')])->haventgetcut(true)->with(['user'])->get()->toArray();
     foreach ($points as $idx => $point) {
         //1. Check tag/category viewed
         $stat = \App\Models\StatUserView::userid($point['user_id'])->statabletype(['App\\Models\\Category', 'App\\Models\\Tag'])->get(['statable_id'])->toArray();
         //1b. Get slugs
         $slugs = [];
         $purchased_prods = [];
         $purchased_varians = [];
         foreach ($stat as $key => $value) {
             $slugs[] = \App\Models\Cluster::find($value['statable_id'])['slug'];
         }
         $purchased = \App\Models\TransactionDetail::TransactionSellOn(['paid', 'packed', 'shipping', 'delivered'])->where('transactions.user_id', $point['user_id'])->groupby('varian_id')->with(['varian', 'varian.product', 'varian.product.clusters'])->get()->toArray();
         foreach ($purchased as $key => $value) {
             //2. Check tag/category purchased
             foreach ($value['varian']['product']['clusters'] as $key2 => $value2) {
                 $slugs[] = $value2['slug'];
             }
             $purchased_prods[] = $value['varian']['product_id'];
             $purchased_varians[] = $value['varian']['size'];
         }
         //2a. get slug of category/tag
         //2b. get product id
         //2c. get varian size
         $slug = array_unique($slugs);
         $productids = array_unique($purchased_prods);
         $variansize = array_unique($purchased_varians);
         $result = \App\Models\Product::sellable(true);
         if (!empty($slug)) {
             $result = $result->clustersslug($slug);
         }
         if (!empty($productids)) {
             $result = $result->notid($productids);
         }
         if (!empty($variansize)) {
             $result = $result->variansize($variansize);
         }
         $product = $result->orderby('price', 'desc')->take(4)->get()->toArray();
         $data = ['point' => $point, 'balin' => $parameters['store'], 'product' => $product];
         //send mail
         Mail::send('mail.' . $parameters['template'] . '.crm.point', ['data' => $data], function ($message) use($point, $parameters) {
             $message->to($point['user']['email'], $point['user']['name'])->subject(strtoupper($parameters['template']) . ' - POINT REMINDER');
         });
         $pnumber = $pending->process_number + 1;
         $messages['message'][$pnumber] = 'Sukses Mengirim Email ' . (isset($point['user']['name']) ? $point['user']['name'] : '');
         $pending->fill(['process_number' => $pnumber, 'message' => json_encode($messages)]);
         $pending->save();
     }
     return true;
 }
开发者ID:ThunderID,项目名称:SHOP-API,代码行数:63,代码来源:PointExpireCommand.php


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