models/Vote.php
public static function isUserCan($model, $userId)
    {
        //if he try vote on its own question
        if (isset($model['user_id']) && $model['user_id'] == $userId) {
            return false;
        } else {
            return !self::find()->where([
                'user_id' => $userId,
                'entity' => self::modelEntityType($model),
                'entity_id' => $model['id']
            ])->exists();
        }
    }
public static function isUserCan($model, $userId)
    {
        //if he try vote on its own question
        if (isset($model['user_id']) && $model['user_id'] == $userId) {
            return false;
        } else {
            return !self::find()->where([
                'user_id' => $userId,
                'entity' => self::modelEntityType($model),
                'entity_id' => $model['id']
            ])->exists();
        }
    }
public static function isUserCan ( $ model , $ userId ) { //if he try vote on its own question if ( isset ( $ model [ 'user_id' ] ) && $ model [ 'user_id' ] == $ userId ) { return false ; } else { return ! self :: find ( ) -> where ( [ 'user_id' => $ userId , 'entity' => self :: modelEntityType ( $ model ) , 'entity_id' => $ model [ 'id' ] ] ) -> exists ( ) ; } }
Check if current user has access to vote
@param ActiveRecord $model
@param int $userId
@return bool
Check if current user has access to vote