Exemplo n.º 1
0
 public function rules()
 {
     return [[['apikey'], 'required'], [['apikey'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'api_key'], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key'], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key'], [['rank', 'rank_after'], 'exist', 'targetClass' => Rank::className(), 'targetAttribute' => 'key'], [['rank_exp', 'rank_exp_after'], 'integer', 'min' => 0, 'max' => 99], [['level', 'level_after'], 'integer', 'min' => 1, 'max' => 50], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['cash', 'cash_after'], 'integer', 'min' => 0, 'max' => 9999999], [['rank_in_team'], 'integer', 'min' => 1, 'max' => 4], [['kill', 'death'], 'integer', 'min' => 0], [['death_reasons'], 'validateDeathReasons'], [['fest_gender'], 'in', 'range' => ['boy', 'girl']], [['fest_rank'], 'filter', 'filter' => 'strtolower'], [['fest_rank'], 'exist', 'targetClass' => FestTitle::className(), 'targetAttribute' => 'key'], [['my_team_color', 'his_team_color'], 'validateTeamColor'], [['image_judge', 'image_result'], 'safe'], [['image_judge', 'image_result'], 'file', 'maxSize' => 3 * 1024 * 1024, 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageFile', 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageString', 'when' => function ($model, $attr) {
         return is_string($model->{$attr});
     }], [['start_at', 'end_at'], 'integer'], [['agent'], 'string', 'max' => 64], [['agent_version'], 'string', 'max' => 255], [['agent', 'agent_version'], 'required', 'when' => function ($model, $attr) {
         return (string) $this->agent !== '' || (string) $this->agent_version !== '';
     }], [['my_point'], 'integer', 'min' => 0], [['my_team_final_point', 'his_team_final_point'], 'integer', 'min' => 0], [['my_team_final_percent', 'his_team_final_percent'], 'number', 'min' => 0.0, 'max' => 100.0], [['knock_out'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['my_team_count', 'his_team_count'], 'integer', 'min' => 0, 'max' => 100], [['lobby'], 'fixLobby']];
 }
Exemplo n.º 2
0
 public function rules()
 {
     return [[['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key', 'when' => function () {
         return substr($this->rule, 0, 1) !== '@';
     }], [['rule'], 'validateGameMode', 'when' => function () {
         return substr($this->rule, 0, 1) === '@';
     }], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key', 'when' => function () {
         return !in_array(substr($this->weapon, 0, 1), ['@', '+', '*'], true);
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => WeaponType::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '@';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Subweapon::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '+';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Special::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '*';
     }], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['term'], 'in', 'range' => ['this-period', 'last-period', '24h', 'today', 'yesterday', 'term']], [['term_from', 'term_to'], 'date', 'format' => 'yyyy-M-d H:m:s']];
 }
Exemplo n.º 3
0
 public function rules()
 {
     return [[['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key', 'when' => function () {
         return substr($this->rule, 0, 1) !== '@';
     }], [['rule'], 'validateGameMode', 'when' => function () {
         return substr($this->rule, 0, 1) === '@';
     }], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key', 'when' => function () {
         return !in_array(substr($this->weapon, 0, 1), ['@', '+', '*'], true);
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => WeaponType::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '@';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Subweapon::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '+';
     }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Special::className()], 'when' => function () {
         return substr($this->weapon, 0, 1) === '*';
     }], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose']];
 }
Exemplo n.º 4
0
 public function rules()
 {
     return [[['apikey'], 'required'], [['apikey'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'api_key'], [['test'], 'in', 'range' => ['validate', 'dry_run']], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key'], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key'], [['rank', 'rank_after'], 'exist', 'targetClass' => Rank::className(), 'targetAttribute' => 'key'], [['rank_exp', 'rank_exp_after'], 'integer', 'min' => 0, 'max' => 99], [['level', 'level_after'], 'integer', 'min' => 1, 'max' => 50], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['cash', 'cash_after'], 'integer', 'min' => 0, 'max' => 9999999], [['rank_in_team'], 'integer', 'min' => 1, 'max' => 4], [['kill', 'death'], 'integer', 'min' => 0], [['death_reasons'], 'validateDeathReasons'], [['gender'], 'in', 'range' => ['boy', 'girl']], [['fest_title', 'fest_title_after'], 'filter', 'filter' => 'strtolower'], [['fest_title', 'fest_title_after'], 'filter', 'filter' => function ($a) {
         switch ($a) {
             case 'campion':
                 return 'champion';
             case 'friend':
                 return 'fiend';
             default:
                 return $a;
         }
     }], [['fest_title', 'fest_title_after'], 'exist', 'targetClass' => FestTitle::className(), 'targetAttribute' => 'key'], [['fest_exp', 'fest_exp_after'], 'integer', 'min' => 0, 'max' => 99], [['my_team_color', 'his_team_color'], 'validateTeamColor'], [['image_judge', 'image_result'], 'safe'], [['image_judge', 'image_result'], 'file', 'maxSize' => 3 * 1024 * 1024, 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageFile', 'when' => function ($model, $attr) {
         return !is_string($model->{$attr});
     }], [['image_judge', 'image_result'], 'validateImageString', 'when' => function ($model, $attr) {
         return is_string($model->{$attr});
     }], [['start_at', 'end_at'], 'integer'], [['agent'], 'string', 'max' => 64], [['agent_version'], 'string', 'max' => 255], [['agent', 'agent_version'], 'required', 'when' => function ($model, $attr) {
         return (string) $this->agent !== '' || (string) $this->agent_version !== '';
     }], [['agent_custom'], 'string'], [['agent', 'agent_version', 'agent_custom'], 'validateStrictUTF8'], [['automated'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['automated'], 'estimateAutomatedAgent', 'skipOnEmpty' => false], [['my_point'], 'integer', 'min' => 0], [['my_team_final_point', 'his_team_final_point'], 'integer', 'min' => 0], [['my_team_final_percent', 'his_team_final_percent'], 'number', 'min' => 0.0, 'max' => 100.0], [['knock_out'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['my_team_count', 'his_team_count'], 'integer', 'min' => 0, 'max' => 100], [['players'], 'validatePlayers'], [['gears'], 'validateGears'], [['events'], 'validateEvents']];
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRules()
 {
     return $this->hasMany(Rule::className(), ['mode_id' => 'id']);
 }
Exemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRule()
 {
     return $this->hasOne(Rule::className(), ['id' => 'rule_id']);
 }
Exemplo n.º 7
0
 public function rules()
 {
     return [[['lobby_id'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'id'], [['rule_id'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'id'], [['map_id'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'id'], [['weapon_id'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'id']];
 }
Exemplo n.º 8
0
 public function getRules()
 {
     return $this->hasMany(Rule::className(), ['role_id' => 'id'])->asArray();
 }