original_string: protected function performInsert(Builder $query)
      {
          $encryptedFields = static::getEncryptedFields();
          if (count($encryptedFields) && !$this->getEncryptKey()) {
              throw new \RuntimeException("No encryption key specified");
          }
          $originalAttributes = $this->attributes;
          foreach ($encryptedFields as $encryptedField) {
              if (isset($this->attributes[$encryptedField])) {
                  $this->attributes[$encryptedField] = DB::raw(static::getEncryptionService()->getEncryptExpression($this->attributes[$encryptedField], static::getEncryptKey()));
              }
          }
          $inserted = parent::performInsert($query);
  
          // reset the attributes to the decrypted values
          foreach ($encryptedFields as $encryptedField) {
              if (isset($this->attributes[$encryptedField])) {
                  $this->attributes[$encryptedField] = $originalAttributes[$encryptedField];
              }
          }
          return $inserted;
      }
code: protected function performInsert(Builder $query)
      {
          $encryptedFields = static::getEncryptedFields();
          if (count($encryptedFields) && !$this->getEncryptKey()) {
              throw new \RuntimeException("No encryption key specified");
          }
          $originalAttributes = $this->attributes;
          foreach ($encryptedFields as $encryptedField) {
              if (isset($this->attributes[$encryptedField])) {
                  $this->attributes[$encryptedField] = DB::raw(static::getEncryptionService()->getEncryptExpression($this->attributes[$encryptedField], static::getEncryptKey()));
              }
          }
          $inserted = parent::performInsert($query);
  
          // reset the attributes to the decrypted values
          foreach ($encryptedFields as $encryptedField) {
              if (isset($this->attributes[$encryptedField])) {
                  $this->attributes[$encryptedField] = $originalAttributes[$encryptedField];
              }
          }
          return $inserted;
      }
code_tokens: protected function performInsert ( Builder $ query ) { $ encryptedFields = static :: getEncryptedFields ( ) ; if ( count ( $ encryptedFields ) && ! $ this -> getEncryptKey ( ) ) { throw new \ RuntimeException ( "No encryption key specified" ) ; } $ originalAttributes = $ this -> attributes ; foreach ( $ encryptedFields as $ encryptedField ) { if ( isset ( $ this -> attributes [ $ encryptedField ] ) ) { $ this -> attributes [ $ encryptedField ] = DB :: raw ( static :: getEncryptionService ( ) -> getEncryptExpression ( $ this -> attributes [ $ encryptedField ] , static :: getEncryptKey ( ) ) ) ; } } $ inserted = parent :: performInsert ( $ query ) ; // reset the attributes to the decrypted values foreach ( $ encryptedFields as $ encryptedField ) { if ( isset ( $ this -> attributes [ $ encryptedField ] ) ) { $ this -> attributes [ $ encryptedField ] = $ originalAttributes [ $ encryptedField ] ; } } return $ inserted ; }
docstring: Perform insert with encryption
  @param Builder $query
  @return bool
docstring_tokens: Perform insert with encryption