public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         //delete all upvotes and polls
         YBoardUpvoted::deleteAll(['poll_id' => $this->id]);
         return true;
     } else {
         return false;
     }
 }
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         //delete: Messages(to/from), Ban History, UpVotes, LogTopic
         YBoardMessage::deleteAll(['or', 'sendfrom' => $this->id, 'sendto' => $this->id]);
         // Post(Polls and Votes)
         YBoardVote::deleteAll(['user_id' => $this->id]);
         YBoardUpvoted::deleteAll(['member_id' => $this->id]);
         YBoardPoll::deleteAll(['user_id' => $this->id]);
         YBoardPost::deleteAll(['user_id' => $this->id]);
         //log topic
         YBoardLogTopic::deleteAll(['member_id' => $this->id]);
         //ban
         YBoardBan::deleteAll(['user_id' => $this->id]);
         return true;
     } else {
         return false;
     }
 }
<?php

/* @var $post_id integer */
use app\modules\yboard\YBoard;
use app\modules\yboard\models\YBoardUpvoted;
use app\modules\yboard\models\YBoardMember;
use yii\helpers\Html;
$models = YBoardUpvoted::find()->where(['post_id' => $post_id])->all();
$count = count($models);
if ($count) {
    echo '<div class="post-upvote-footer">' . PHP_EOL;
    echo YBoard::t('yboard', 'This post is appreciated by {no} member{plural}', ['no' => $count, 'plural' => $count > 1 ? 's' : '']) . ' ';
    $users = [];
    foreach ($models as $model) {
        $member = YBoardMember::findOne($model->member_id);
        if ($member !== null) {
            $users[] = Html::a(Html::encode($member->profile->username), ["member/view", "id" => $member->id], ['target' => '_blank']);
        }
    }
    $members = '<b>' . implode(', ', $users) . '</b>';
    echo Html::a(YBoard::t('yboard', '[view]'), '#', ['onclick' => 'showAppreciation(\'' . $members . '\'); return false;']);
    echo '</div>' . PHP_EOL;
}
 public function showUpvote($post_id)
 {
     $url = Yii::$app->urlManager->createAbsoluteUrl($this->module->id . '/forum/upvote');
     $post = YBoardPost::findOne($post_id);
     if ($post === null || $post->user_id == Yii::$app->user->id) {
         return '';
     }
     $upvoted = YBoardUpvoted::find()->where(['member_id' => Yii::$app->user->identity->id])->andWhere(['post_id' => $post_id])->count();
     if ($upvoted > 0) {
         $html = Html::button(YBoard::t('yboard', 'Downvote') . ' <span class="glyphicon glyphicon-chevron-down"></span>', ['class' => 'btn btn-sm btn-default', 'title' => YBoard::t('yboard', 'Remove your appreciation'), 'id' => 'upvote_' . $post_id, 'style' => 'cursor:pointer;', 'onclick' => 'upvotePost(' . $post_id . ',' . $post->user_id . ',"' . $url . '")']);
     } else {
         $html = Html::button(YBoard::t('yboard', 'Upvote') . ' <span class="glyphicon glyphicon-chevron-up"></span>', ['class' => 'btn btn-sm btn-default', 'title' => YBoard::t('yboard', 'Appreciate this post'), 'id' => 'upvote_' . $post_id, 'style' => 'cursor:pointer;', 'onclick' => 'upvotePost(' . $post_id . ',' . $post->user_id . ',"' . $url . '")']);
     }
     return $html;
 }