class User extends ActiveRecord implements IdentityInterface { const STATUS_DELETED = 0; const STATUS_ACTIVE = 10; // ... public function rules() { return [ ['status', 'default', 'value' => self::STATUS_ACTIVE], ['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]], ['status', 'filter', 'filter' => 'intval'], // ... ]; } // Get the label for the current status public function getStatusLabel() { $statuses = self::getStatuses(); return ArrayHelper::getValue($statuses, $this->status); } // Get an array of status labels, indexed by status constants public static function getStatuses() { return [ self::STATUS_DELETED => Yii::t('user', 'Delete'), self::STATUS_ACTIVE => Yii::t('user', 'Active'), ]; } }