src/Axolotl/Model.php
public function serialize() {
		$attributes = array();

		if ( $this->visible ) {
			// If visible attributes are set, we'll only reveal those.
			foreach ( $this->visible as $key ) {
				$attributes[ $key ] = $this->get_attribute( $key );
			}
		} elseif ( $this->hidden ) {
			// If hidden attributes are set, we'll grab everything and hide those.
			foreach ( $this->get_attribute_keys() as $key ) {
				if ( ! in_array( $key, $this->hidden ) ) {
					$attributes[ $key ] = $this->get_attribute( $key );
				}
			}
		} else {
			// If nothing is hidden/visible, we'll grab and reveal everything.
			foreach ( $this->get_attribute_keys() as $key ) {
				$attributes[ $key ] = $this->get_attribute( $key );
			}
		}

		return array_map( function ( $attribute ) {
			if ( $attribute instanceof Serializes ) {
				return $attribute->serialize();
			}

			return $attribute;
		}, $attributes );
	}
public function serialize() {
		$attributes = array();

		if ( $this->visible ) {
			// If visible attributes are set, we'll only reveal those.
			foreach ( $this->visible as $key ) {
				$attributes[ $key ] = $this->get_attribute( $key );
			}
		} elseif ( $this->hidden ) {
			// If hidden attributes are set, we'll grab everything and hide those.
			foreach ( $this->get_attribute_keys() as $key ) {
				if ( ! in_array( $key, $this->hidden ) ) {
					$attributes[ $key ] = $this->get_attribute( $key );
				}
			}
		} else {
			// If nothing is hidden/visible, we'll grab and reveal everything.
			foreach ( $this->get_attribute_keys() as $key ) {
				$attributes[ $key ] = $this->get_attribute( $key );
			}
		}

		return array_map( function ( $attribute ) {
			if ( $attribute instanceof Serializes ) {
				return $attribute->serialize();
			}

			return $attribute;
		}, $attributes );
	}
public function serialize ( ) { $ attributes = array ( ) ; if ( $ this -> visible ) { // If visible attributes are set, we'll only reveal those. foreach ( $ this -> visible as $ key ) { $ attributes [ $ key ] = $ this -> get_attribute ( $ key ) ; } } elseif ( $ this -> hidden ) { // If hidden attributes are set, we'll grab everything and hide those. foreach ( $ this -> get_attribute_keys ( ) as $ key ) { if ( ! in_array ( $ key , $ this -> hidden ) ) { $ attributes [ $ key ] = $ this -> get_attribute ( $ key ) ; } } } else { // If nothing is hidden/visible, we'll grab and reveal everything. foreach ( $ this -> get_attribute_keys ( ) as $ key ) { $ attributes [ $ key ] = $ this -> get_attribute ( $ key ) ; } } return array_map ( function ( $ attribute ) { if ( $ attribute instanceof Serializes ) { return $ attribute -> serialize ( ) ; } return $ attribute ; } , $ attributes ) ; }
Serializes the model's public data into an array.

@return array
Serializes the model s public data into an array .