0


views\site\vote.php:

<?php Pjax::begin(['enablePushState' => false]); ?>
<?= Html::a('', ['site/upvote'], ['class' => 'btn btn-lg btn-warning glyphicon glyphicon-arrow-up']) ?>
<?= Html::a('', ['site/downvote'], ['class' => 'btn btn-lg btn-primary glyphicon glyphicon-arrow-down']) ?>
<h1><?= Yii::$app->session->get('votes', 0) ?></h1>
<?php Pjax::end(); ?>

controllers\SiteController.php:
public function actionVote()
{
    return $this->render('vote');
}

public function actionUpvote()
{
    $votes = Yii::$app->session->get('votes', 0);
    Yii::$app->session->set('votes', ++$votes);
    return $this->render('vote');
}

public function actionDownvote()
{
    $votes = Yii::$app->session->get('votes', 0);
    Yii::$app->session->set('votes', --$votes);
    return $this->render('vote');
}