ArticleMetaDislike.php 729 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2016-11-10 10:50
  7. */
  8. namespace common\models\meta;
  9. use Yii;
  10. class ArticleMetaDislike extends \common\models\ArticleMeta
  11. {
  12. public $keyName = "dislike";
  13. /**
  14. * @param $aid
  15. * @param int $value
  16. */
  17. public function setDislike($aid)
  18. {
  19. $this->aid = $aid;
  20. $this->key = $this->keyName;
  21. $this->value = Yii::$app->getRequest()->getUserIP();
  22. $this->save(false);
  23. }
  24. /**
  25. * @param $aid
  26. * @return int|string
  27. */
  28. public function getDislikeCount($aid)
  29. {
  30. return $this->find()->where(['aid' => $aid, 'key' => $this->keyName])->count("aid");
  31. }
  32. }