예제 #1
0
 /**
  * @param $tagId
  * @param $productId
  * @param $type
  * @return bool
  */
 public function createItem($tagId, $productId, $type)
 {
     $productTag = new productTagModel();
     $productTag->tag_id = $tagId;
     $productTag->product_id = $productId;
     $productTag->type = $type;
     return $productTag->save();
 }
예제 #2
0
 /**
  * @param $data
  * @param $productId
  * @param $type
  */
 public function updateTagProduct($data, $productId, $type)
 {
     $productTagModel = new productTagModel();
     $productTagModel->removeItem($productId, $type);
     if (isset($data['productTag_' . $type]) && $data['productTag_' . $type]) {
         foreach ($data['productTag_' . $type] as $tagId) {
             $tagCache = '__count_search_product_by_tag_id__';
             Cache::tags($tagCache)->flush();
             $productTagModel->createItem($tagId, $productId, $type);
         }
     }
 }