public function save( array $options = array() ) {

		if ( isset( $options['exclude_relations'] ) && ! is_array( $options['exclude_relations'] ) ) {
			$options['exclude_relations'] = (array) $options['exclude_relations'];
		}

		$columns = static::table()->get_columns();

		$options = wp_parse_args( $options, array(
			'exclude_relations' => array_filter( $this->get_all_relations(), function ( $attribute ) use ( $columns ) {
				return array_key_exists( $attribute, $columns );
			} )
		) );

		$this->fire_model_event( 'saving' );

		$this->save_has_foreign_relations();

		if ( $this->exists() ) {
			$saved = $this->do_save_as_update();
		} else {
			$saved = $this->do_save_as_insert();
		}

		$this->save_loaded_relations( $options['exclude_relations'] );

		if ( $saved ) {
			$this->finish_save();
		}

		return $saved;
	}
public function save( array $options = array() ) {

		if ( isset( $options['exclude_relations'] ) && ! is_array( $options['exclude_relations'] ) ) {
			$options['exclude_relations'] = (array) $options['exclude_relations'];
		}

		$columns = static::table()->get_columns();

		$options = wp_parse_args( $options, array(
			'exclude_relations' => array_filter( $this->get_all_relations(), function ( $attribute ) use ( $columns ) {
				return array_key_exists( $attribute, $columns );
			} )
		) );

		$this->fire_model_event( 'saving' );

		$this->save_has_foreign_relations();

		if ( $this->exists() ) {
			$saved = $this->do_save_as_update();
		} else {
			$saved = $this->do_save_as_insert();
		}

		$this->save_loaded_relations( $options['exclude_relations'] );

		if ( $saved ) {
			$this->finish_save();
		}

		return $saved;
	}
public function save ( array $ options = array ( ) ) { if ( isset ( $ options [ 'exclude_relations' ] ) && ! is_array ( $ options [ 'exclude_relations' ] ) ) { $ options [ 'exclude_relations' ] = ( array ) $ options [ 'exclude_relations' ] ; } $ columns = static :: table ( ) -> get_columns ( ) ; $ options = wp_parse_args ( $ options , array ( 'exclude_relations' => array_filter ( $ this -> get_all_relations ( ) , function ( $ attribute ) use ( $ columns ) { return array_key_exists ( $ attribute , $ columns ) ; } ) ) ) ; $ this -> fire_model_event ( 'saving' ) ; $ this -> save_has_foreign_relations ( ) ; if ( $ this -> exists ( ) ) { $ saved = $ this -> do_save_as_update ( ) ; } else { $ saved = $ this -> do_save_as_insert ( ) ; } $ this -> save_loaded_relations ( $ options [ 'exclude_relations' ] ) ; if ( $ saved ) { $ this -> finish_save ( ) ; } return $ saved ; }
Persist this model's changes to the database.

This will save all savable attributes like WP_Post objects or Models,
and persist any loaded relations.

The `saving` and `saved` events will be fired. If this model does not yet exist, the `creating` and `created`
events will fire as well. Otherwise, the `updating` and `updated` events will fire.

@since 2.0

@param array $options Configure how the saving should be performed.
Accepts 'exclude_relations' to allow for given relations to be excluded from persistence.

@return bool

@throws Exception
Persist this model s changes to the database .