Exemple #1
0
 public static function getViewsLikes($id)
 {
     $arr = (new Query())->select(['likes', 'views', 'rating_all', 'id_author'])->from('club_photo')->where(['id' => $id])->one();
     $arr['isLike'] = 0;
     Photo::formRating($arr['rating_all']);
     if (!Yii::$app->user->isGuest) {
         $tmp = (new Query())->select('count(1)')->from('club_likes')->where(['user_id' => Yii::$app->user->getId(), 'photo_id' => $id])->scalar();
         if ($tmp) {
             $arr['isLike'] = 1;
         }
     }
     return $arr;
 }