src/mako/database/midgard/ORM.php
public function toArray(): array
	{
		$columns = $this->columns;

		// Removes protected columns from the array

		if(!empty($this->protected))
		{
			$columns = array_diff_key($columns, array_flip($this->protected));
		}

		// Mutate column values if needed

		foreach($columns as $name => $value)
		{
			$value = $this->getColumnValue($name);

			if($value instanceof DateTimeInterface)
			{
				$value = $value->format($this->dateOutputFormat);
			}

			$columns[$name] = $value;
		}

		// Merge in related records

		foreach($this->related as $relation => $related)
		{
			if(in_array($relation, $this->protected))
			{
				continue;
			}

			$columns += [$relation => ($related === false ? $related : $related->toArray())];
		}

		// Returns array representation of the record

		return $columns;
	}
public function toArray(): array
	{
		$columns = $this->columns;

		// Removes protected columns from the array

		if(!empty($this->protected))
		{
			$columns = array_diff_key($columns, array_flip($this->protected));
		}

		// Mutate column values if needed

		foreach($columns as $name => $value)
		{
			$value = $this->getColumnValue($name);

			if($value instanceof DateTimeInterface)
			{
				$value = $value->format($this->dateOutputFormat);
			}

			$columns[$name] = $value;
		}

		// Merge in related records

		foreach($this->related as $relation => $related)
		{
			if(in_array($relation, $this->protected))
			{
				continue;
			}

			$columns += [$relation => ($related === false ? $related : $related->toArray())];
		}

		// Returns array representation of the record

		return $columns;
	}
public function toArray ( ) : array { $ columns = $ this -> columns ; // Removes protected columns from the array if ( ! empty ( $ this -> protected ) ) { $ columns = array_diff_key ( $ columns , array_flip ( $ this -> protected ) ) ; } // Mutate column values if needed foreach ( $ columns as $ name => $ value ) { $ value = $ this -> getColumnValue ( $ name ) ; if ( $ value instanceof DateTimeInterface ) { $ value = $ value -> format ( $ this -> dateOutputFormat ) ; } $ columns [ $ name ] = $ value ; } // Merge in related records foreach ( $ this -> related as $ relation => $ related ) { if ( in_array ( $ relation , $ this -> protected ) ) { continue ; } $ columns += [ $ relation => ( $ related === false ? $ related : $ related -> toArray ( ) ) ] ; } // Returns array representation of the record return $ columns ; }
Returns an array representation of the record.

@return array
Returns an array representation of the record .