public function isFollowing($userId) { return FeedFollower::model()->exists('user_id = :user_id && feed_id = :feed_id', array(':user_id' => $userId, ':feed_id' => $this->id)); }
public function actionUnfollow($id) { $feed = $this->loadModel($id); $feedFollower = FeedFollower::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'feed_id' => $feed->id)); echo function_exists('json_encode') ? json_encode(!$feedFollower || $feedFollower->delete()) : CJSON::encode(!$feedFollower || $feedFollower->delete()); }