original_string: protected static function gatherRules()
      {
          // This rather gnarly looking logic is just for developer convenience
          // so he can define multiple rule groups on the model for clarity
          // and now we simply gather all rules and merge them together.
          $keys = static::getValidatedFields();
  
          $result = array_fill_keys($keys, []);
  
          foreach ($keys as $key) {
              foreach (static::getRulesGroups() as $groupName) {
                  $group = static::getRulesGroup($groupName);
  
                  if (isset($group[$key])) {
                      $rules = is_array($group[$key])
                              ? $group[$key]
                              : explode('|', $group[$key]);
  
                      foreach ($rules as &$rule) {
                          if ($rule === 'unique') {
                              $table = (new static)->getTable();
  
                              $rule .= ":{$table}";
                          }
                      }
  
                      unset($rule);
  
                      $result[$key] = array_unique(array_merge($result[$key], $rules));
                  }
              }
          }
  
          return $result;
      }
code: protected static function gatherRules()
      {
          // This rather gnarly looking logic is just for developer convenience
          // so he can define multiple rule groups on the model for clarity
          // and now we simply gather all rules and merge them together.
          $keys = static::getValidatedFields();
  
          $result = array_fill_keys($keys, []);
  
          foreach ($keys as $key) {
              foreach (static::getRulesGroups() as $groupName) {
                  $group = static::getRulesGroup($groupName);
  
                  if (isset($group[$key])) {
                      $rules = is_array($group[$key])
                              ? $group[$key]
                              : explode('|', $group[$key]);
  
                      foreach ($rules as &$rule) {
                          if ($rule === 'unique') {
                              $table = (new static)->getTable();
  
                              $rule .= ":{$table}";
                          }
                      }
  
                      unset($rule);
  
                      $result[$key] = array_unique(array_merge($result[$key], $rules));
                  }
              }
          }
  
          return $result;
      }
code_tokens: protected static function gatherRules ( ) { // This rather gnarly looking logic is just for developer convenience // so he can define multiple rule groups on the model for clarity // and now we simply gather all rules and merge them together. $ keys = static :: getValidatedFields ( ) ; $ result = array_fill_keys ( $ keys , [ ] ) ; foreach ( $ keys as $ key ) { foreach ( static :: getRulesGroups ( ) as $ groupName ) { $ group = static :: getRulesGroup ( $ groupName ) ; if ( isset ( $ group [ $ key ] ) ) { $ rules = is_array ( $ group [ $ key ] ) ? $ group [ $ key ] : explode ( '|' , $ group [ $ key ] ) ; foreach ( $ rules as & $ rule ) { if ( $ rule === 'unique' ) { $ table = ( new static ) -> getTable ( ) ; $ rule .= ":{$table}" ; } } unset ( $ rule ) ; $ result [ $ key ] = array_unique ( array_merge ( $ result [ $ key ] , $ rules ) ) ; } } } return $ result ; }
docstring: Gather all the rules for the model and store it for easier use.
  
  @return array
docstring_tokens: Gather all the rules for the model and store it for easier use .