public function transformToArray($data, $nestedInclude = true, $extraIncludes = [], $callback = null)
	{

		if (is_object($data))
		{

			if( $nestedInclude && ! $this->resolved($data) )
			{
				$objectKey = $this->objectKey($data);
				
				if(array_key_exists($objectKey, $extraIncludes))
				{
					$data = $extraIncludes[$objectKey];
				}
				else
				{
					$data = $this->getIncluded($data);
				}
				
			}

			if($data instanceof DataTransferObject)
			{
				// $data->addIncludes($this->included);
				$data = $data->transformToArray($data->getData(), $nestedInclude, $this->included + $extraIncludes);
			}
			elseif($data instanceof Carbon)
			{
				$data = $data->tz('UTC')->toIso8601String();
			}
			else
			{
				$data = get_object_vars($data);
			}
		}


		
		if ( is_array($data) && ! empty($data) )
		{

			foreach ($data as $key => &$value)
			{
				$this->transformAttribute($data, $key, $value, $nestedInclude, $this->included + $extraIncludes, $callback);
			}
			
		}

		if(is_callable($callback))
		{
			$data = call_user_func_array($callback, [[], 0, $data, $nestedInclude, $extraIncludes]);
		}

		return $data;
	}
public function transformToArray($data, $nestedInclude = true, $extraIncludes = [], $callback = null)
	{

		if (is_object($data))
		{

			if( $nestedInclude && ! $this->resolved($data) )
			{
				$objectKey = $this->objectKey($data);
				
				if(array_key_exists($objectKey, $extraIncludes))
				{
					$data = $extraIncludes[$objectKey];
				}
				else
				{
					$data = $this->getIncluded($data);
				}
				
			}

			if($data instanceof DataTransferObject)
			{
				// $data->addIncludes($this->included);
				$data = $data->transformToArray($data->getData(), $nestedInclude, $this->included + $extraIncludes);
			}
			elseif($data instanceof Carbon)
			{
				$data = $data->tz('UTC')->toIso8601String();
			}
			else
			{
				$data = get_object_vars($data);
			}
		}


		
		if ( is_array($data) && ! empty($data) )
		{

			foreach ($data as $key => &$value)
			{
				$this->transformAttribute($data, $key, $value, $nestedInclude, $this->included + $extraIncludes, $callback);
			}
			
		}

		if(is_callable($callback))
		{
			$data = call_user_func_array($callback, [[], 0, $data, $nestedInclude, $extraIncludes]);
		}

		return $data;
	}
public function transformToArray ( $ data , $ nestedInclude = true , $ extraIncludes = [ ] , $ callback = null ) { if ( is_object ( $ data ) ) { if ( $ nestedInclude && ! $ this -> resolved ( $ data ) ) { $ objectKey = $ this -> objectKey ( $ data ) ; if ( array_key_exists ( $ objectKey , $ extraIncludes ) ) { $ data = $ extraIncludes [ $ objectKey ] ; } else { $ data = $ this -> getIncluded ( $ data ) ; } } if ( $ data instanceof DataTransferObject ) { // $data->addIncludes($this->included); $ data = $ data -> transformToArray ( $ data -> getData ( ) , $ nestedInclude , $ this -> included + $ extraIncludes ) ; } elseif ( $ data instanceof Carbon ) { $ data = $ data -> tz ( 'UTC' ) -> toIso8601String ( ) ; } else { $ data = get_object_vars ( $ data ) ; } } if ( is_array ( $ data ) && ! empty ( $ data ) ) { foreach ( $ data as $ key => & $ value ) { $ this -> transformAttribute ( $ data , $ key , $ value , $ nestedInclude , $ this -> included + $ extraIncludes , $ callback ) ; } } if ( is_callable ( $ callback ) ) { $ data = call_user_func_array ( $ callback , [ [ ] , 0 , $ data , $ nestedInclude , $ extraIncludes ] ) ; } return $ data ; }
Convert Object to array deep

@param  object $data

@return array
Convert Object to array deep