Model::syncModel( $columns = array() )


Source

File: Model/Model.php

	protected function syncModel( $columns = [] ) {
		$this->columns = array_merge( $this->columns, $columns );

		$columns = $this->columns;

		if ( ! empty( $columns[ $this->primaryKey ] ) ) {
			$primary_key = $columns[ $this->primaryKey ];
			unset( $columns[ $this->primaryKey ] );

			$columns = array_merge( [ $this->primaryKey => $primary_key ], $columns );
		}

		foreach ( $columns as $property => $value ) {
			$this->{$property} = $value;
		}

		$this->columns = $columns;
	}