BitmaskTrait.php 455 Bytes
<?php
    
    namespace artbox\catalog\models\traits;
    
    trait BitmaskTrait
    {
        /**
         * @param       $condition
         * @param array $params
         *
         * @return \yii\db\ActiveQuery
         */
        abstract public function andWhere($condition, $params = []);
        
        public function is($attribute, $value)
        {
            return $this->andWhere($attribute . ' & ' . $value . ' != 0');
        }
    }