original_string: public function save($cascade = null, $use_transaction = false)
  	{
  		// Load temporal properties.
  		$timestamp_start_name = static::temporal_property('start_column');
  		$timestamp_end_name = static::temporal_property('end_column');
  		$mysql_timestamp = static::temporal_property('mysql_timestamp');
  
  		$max_timestamp = static::temporal_property('max_timestamp');
  		$current_timestamp = $mysql_timestamp ?
  			\Date::forge()->format('mysql') :
  			\Date::forge()->get_timestamp();
  
  		// If this is new then just call the parent and let everything happen as normal
  		if ($this->is_new())
  		{
  			static::disable_primary_key_check();
  			$this->{$timestamp_start_name} = $current_timestamp;
  			$this->{$timestamp_end_name} = $max_timestamp;
  			static::enable_primary_key_check();
  
  			// Make sure save will populate the PK
  			static::enable_id_only_primary_key();
  			$result = parent::save($cascade, $use_transaction);
  			static::disable_id_only_primary_key();
  
  			return $result;
  		}
  		// If this is an update then set a new PK, save and then insert a new row
  		else
  		{
  			// run the before save observers before checking the diff
  			$this->observe('before_save');
  
  			// then disable it so it doesn't get executed by parent::save()
  			$this->disable_event('before_save');
  
  			$diff = $this->get_diff();
  
  			if (count($diff[0]) > 0)
  			{
  				// Take a copy of this model
  				$revision = clone $this;
  
  				// Give that new model an end time of the current time after resetting back to the old data
  				$revision->set($this->_original);
  
  				self::disable_primary_key_check();
  				$revision->{$timestamp_end_name} = $current_timestamp;
  				self::enable_primary_key_check();
  
  				// Make sure relations stay the same
  				$revision->_original_relations = $this->_data_relations;
  
  				// save that, now we have our archive
  				self::enable_id_only_primary_key();
  				$revision_result = $revision->overwrite(false, $use_transaction);
  				self::disable_id_only_primary_key();
  
  				if ( ! $revision_result)
  				{
  					// If the revision did not save then stop the process so the user can do something.
  					return false;
  				}
  
  				// Now that the old data is saved update the current object so its end timestamp is now
  				self::disable_primary_key_check();
  				$this->{$timestamp_start_name} = $current_timestamp;
  				self::enable_primary_key_check();
  
  				$result = parent::save($cascade, $use_transaction);
  			}
  			else
  			{
  				// If nothing has changed call parent::save() to insure relations are saved too
  				$result = parent::save($cascade, $use_transaction);
  			}
  
  			// make sure the before save event is enabled again
  			$this->enable_event('before_save');
  
  			return $result;
  		}
  	}
code: public function save($cascade = null, $use_transaction = false)
  	{
  		// Load temporal properties.
  		$timestamp_start_name = static::temporal_property('start_column');
  		$timestamp_end_name = static::temporal_property('end_column');
  		$mysql_timestamp = static::temporal_property('mysql_timestamp');
  
  		$max_timestamp = static::temporal_property('max_timestamp');
  		$current_timestamp = $mysql_timestamp ?
  			\Date::forge()->format('mysql') :
  			\Date::forge()->get_timestamp();
  
  		// If this is new then just call the parent and let everything happen as normal
  		if ($this->is_new())
  		{
  			static::disable_primary_key_check();
  			$this->{$timestamp_start_name} = $current_timestamp;
  			$this->{$timestamp_end_name} = $max_timestamp;
  			static::enable_primary_key_check();
  
  			// Make sure save will populate the PK
  			static::enable_id_only_primary_key();
  			$result = parent::save($cascade, $use_transaction);
  			static::disable_id_only_primary_key();
  
  			return $result;
  		}
  		// If this is an update then set a new PK, save and then insert a new row
  		else
  		{
  			// run the before save observers before checking the diff
  			$this->observe('before_save');
  
  			// then disable it so it doesn't get executed by parent::save()
  			$this->disable_event('before_save');
  
  			$diff = $this->get_diff();
  
  			if (count($diff[0]) > 0)
  			{
  				// Take a copy of this model
  				$revision = clone $this;
  
  				// Give that new model an end time of the current time after resetting back to the old data
  				$revision->set($this->_original);
  
  				self::disable_primary_key_check();
  				$revision->{$timestamp_end_name} = $current_timestamp;
  				self::enable_primary_key_check();
  
  				// Make sure relations stay the same
  				$revision->_original_relations = $this->_data_relations;
  
  				// save that, now we have our archive
  				self::enable_id_only_primary_key();
  				$revision_result = $revision->overwrite(false, $use_transaction);
  				self::disable_id_only_primary_key();
  
  				if ( ! $revision_result)
  				{
  					// If the revision did not save then stop the process so the user can do something.
  					return false;
  				}
  
  				// Now that the old data is saved update the current object so its end timestamp is now
  				self::disable_primary_key_check();
  				$this->{$timestamp_start_name} = $current_timestamp;
  				self::enable_primary_key_check();
  
  				$result = parent::save($cascade, $use_transaction);
  			}
  			else
  			{
  				// If nothing has changed call parent::save() to insure relations are saved too
  				$result = parent::save($cascade, $use_transaction);
  			}
  
  			// make sure the before save event is enabled again
  			$this->enable_event('before_save');
  
  			return $result;
  		}
  	}
code_tokens: public function save ( $ cascade = null , $ use_transaction = false ) { // Load temporal properties. $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; $ mysql_timestamp = static :: temporal_property ( 'mysql_timestamp' ) ; $ max_timestamp = static :: temporal_property ( 'max_timestamp' ) ; $ current_timestamp = $ mysql_timestamp ? \ Date :: forge ( ) -> format ( 'mysql' ) : \ Date :: forge ( ) -> get_timestamp ( ) ; // If this is new then just call the parent and let everything happen as normal if ( $ this -> is_new ( ) ) { static :: disable_primary_key_check ( ) ; $ this -> { $ timestamp_start_name } = $ current_timestamp ; $ this -> { $ timestamp_end_name } = $ max_timestamp ; static :: enable_primary_key_check ( ) ; // Make sure save will populate the PK static :: enable_id_only_primary_key ( ) ; $ result = parent :: save ( $ cascade , $ use_transaction ) ; static :: disable_id_only_primary_key ( ) ; return $ result ; } // If this is an update then set a new PK, save and then insert a new row else { // run the before save observers before checking the diff $ this -> observe ( 'before_save' ) ; // then disable it so it doesn't get executed by parent::save() $ this -> disable_event ( 'before_save' ) ; $ diff = $ this -> get_diff ( ) ; if ( count ( $ diff [ 0 ] ) > 0 ) { // Take a copy of this model $ revision = clone $ this ; // Give that new model an end time of the current time after resetting back to the old data $ revision -> set ( $ this -> _original ) ; self :: disable_primary_key_check ( ) ; $ revision -> { $ timestamp_end_name } = $ current_timestamp ; self :: enable_primary_key_check ( ) ; // Make sure relations stay the same $ revision -> _original_relations = $ this -> _data_relations ; // save that, now we have our archive self :: enable_id_only_primary_key ( ) ; $ revision_result = $ revision -> overwrite ( false , $ use_transaction ) ; self :: disable_id_only_primary_key ( ) ; if ( ! $ revision_result ) { // If the revision did not save then stop the process so the user can do something. return false ; } // Now that the old data is saved update the current object so its end timestamp is now self :: disable_primary_key_check ( ) ; $ this -> { $ timestamp_start_name } = $ current_timestamp ; self :: enable_primary_key_check ( ) ; $ result = parent :: save ( $ cascade , $ use_transaction ) ; } else { // If nothing has changed call parent::save() to insure relations are saved too $ result = parent :: save ( $ cascade , $ use_transaction ) ; } // make sure the before save event is enabled again $ this -> enable_event ( 'before_save' ) ; return $ result ; } }
docstring: Overrides the save method to allow temporal models to be
  @param boolean $cascade
  @param boolean $use_transaction
  @param boolean $skip_temporal Skips temporal filtering on initial inserts. Should not be used!
  @return boolean
docstring_tokens: Overrides the save method to allow temporal models to be