original_string: public function sync($attributes)
      {
          if (isset($attributes['$id'])) {
              $this->state = static::STATE_ATTACHED;
              $this->id = $attributes['$id'];
          } else {
              foreach ($this->schema() as $key => $field) {
                  if ($field->has('default')) {
                      $attributes[$key] = $field['default'];
                  }
              }
  
              $this->state = static::STATE_DETACHED;
          }
  
          $this->set($attributes);
          $this->populateOld();
      }
code: public function sync($attributes)
      {
          if (isset($attributes['$id'])) {
              $this->state = static::STATE_ATTACHED;
              $this->id = $attributes['$id'];
          } else {
              foreach ($this->schema() as $key => $field) {
                  if ($field->has('default')) {
                      $attributes[$key] = $field['default'];
                  }
              }
  
              $this->state = static::STATE_DETACHED;
          }
  
          $this->set($attributes);
          $this->populateOld();
      }
code_tokens: public function sync ( $ attributes ) { if ( isset ( $ attributes [ '$id' ] ) ) { $ this -> state = static :: STATE_ATTACHED ; $ this -> id = $ attributes [ '$id' ] ; } else { foreach ( $ this -> schema ( ) as $ key => $ field ) { if ( $ field -> has ( 'default' ) ) { $ attributes [ $ key ] = $ field [ 'default' ] ; } } $ this -> state = static :: STATE_DETACHED ; } $ this -> set ( $ attributes ) ; $ this -> populateOld ( ) ; }
docstring: Sync the existing attributes with new values. After update or insert, this method used to modify the existing attributes.
  
  @param array $attributes
  
  @return void
docstring_tokens: Sync the existing attributes with new values . After update or insert this method used to modify the existing attributes .