/**
  * @param $userId
  * @param $productId
  * @param $url
  * @return bool
  */
 public function createItem($userId, $productId, $url)
 {
     $userProductLike = new userProductLikeModel();
     $userProductLike->user_id = $userId;
     $userProductLike->product_id = $productId;
     $userProductLike->product_url = $url;
     return $userProductLike->save();
 }
Beispiel #2
0
 /**
  * @param $dateRange
  * @param $type
  * @return mixed
  */
 public function getUserProductLikeReport($dateRange, $type)
 {
     if (!$dateRange) {
         $startTime = Carbon::now()->subDays(KACANA_REPORT_DURATION_DEFAULT);
         $endTime = Carbon::now();
     } else {
         $dateRange = explode(' - ', $dateRange);
         $startTime = $dateRange[0];
         $endTime = Carbon::createFromFormat('Y-m-d', $dateRange[1])->addDay();
     }
     return $this->_userProductLike->reportUserProductLike($startTime, $endTime, $type);
 }
Beispiel #3
0
 /**
  * @param $searchString
  * @param int $limit
  * @param int $page
  * @param bool $options
  * @return bool|\Illuminate\Pagination\LengthAwarePaginator
  */
 public function searchProduct($searchString, $limit = KACANA_PRODUCT_ITEM_PER_TAG, $page = 1, $options = false, $userId)
 {
     $productModel = new productModel();
     $userProductLike = new userProductLikeModel();
     $products = $productModel->searchProduct($searchString, $limit, $page, $options);
     foreach ($products as &$product) {
         $this->formatProductPropertiesWhenSearch($product);
         $product->isLiked = $userProductLike->getItem($userId, $product->id) ? true : false;
     }
     return $products;
 }