Exemplo n.º 1
0
 /**
  * 喜欢的用户
  */
 public function getLikes($uid)
 {
     $gid = $this->id ? $this->id : 0;
     $likeModels = GoodsLikeModel::where(array('gid' => $gid, 'uid' => $uid))->get();
     return count($likeModels) ? count($likeModels) : 0;
 }
Exemplo n.º 2
0
 /**
  * 喜欢量,每个会员一次
  */
 public function userLike($id)
 {
     if (!\Session::has('user.uid')) {
         return redirect('/login');
     }
     $userid = \Session::get('user.uid');
     $arr = array('gid' => $id, 'uid' => $userid);
     $userLike = GoodsLikeModel::where($arr)->first();
     if ($userLike) {
         GoodsLikeModel::where($arr)->delete();
     } else {
         $arr['created_at'] = time();
         GoodsLikeModel::create($arr);
     }
     return redirect(DOMAIN . 'product');
 }