public function updateViewCounter()
    {
        $userId = Yii::$app->user->id;
        $viewCount = $this->viewCount;

        if (!empty($viewCount)) {
            $viewCount->updateCounters(['count' => 1]);
        } else {
            $viewCount = new ArticleViewCount();
            $viewCount->article_id = $this->id;
            $viewCount->viewer_id = $userId;
            $viewCount->save();
            $viewCount->updateCounters(['count' => 1]);
        }

        return $viewCount;
    }
public function updateViewCounter()
    {
        $userId = Yii::$app->user->id;
        $viewCount = $this->viewCount;

        if (!empty($viewCount)) {
            $viewCount->updateCounters(['count' => 1]);
        } else {
            $viewCount = new ArticleViewCount();
            $viewCount->article_id = $this->id;
            $viewCount->viewer_id = $userId;
            $viewCount->save();
            $viewCount->updateCounters(['count' => 1]);
        }

        return $viewCount;
    }
public function updateViewCounter ( ) { $ userId = Yii :: $ app -> user -> id ; $ viewCount = $ this -> viewCount ; if ( ! empty ( $ viewCount ) ) { $ viewCount -> updateCounters ( [ 'count' => 1 ] ) ; } else { $ viewCount = new ArticleViewCount ( ) ; $ viewCount -> article_id = $ this -> id ; $ viewCount -> viewer_id = $ userId ; $ viewCount -> save ( ) ; $ viewCount -> updateCounters ( [ 'count' => 1 ] ) ; } return $ viewCount ; }
Updates views counter.

@return null|ArticleViewCount
Updates views counter .