private function formatHasOne()
    {
        // Return if there are no relationships of that type
        if (!isset($this->relationships['hasOne']) || empty($this->relationships['hasOne'])) {
            return $this;
        }

        // Iterate relationships
        foreach ($this->relationships['hasOne'] as $join) {
            $this->records = array_map(function ($record) use ($join) {
                foreach ($record as $key => $value) {
                    $prefix = '_' . $join['alias'] . '_';
                    if (preg_match('/^' . $prefix . '[\w]+/', $key)) {
                        $record[$join['alias']][str_replace($prefix, '', $key)] = $value;
                        unset($record[$key]);
                    }
                }
                return $record;
            }, $this->records);
        }

        // Return model instance
        return $this;
    }
private function formatHasOne()
    {
        // Return if there are no relationships of that type
        if (!isset($this->relationships['hasOne']) || empty($this->relationships['hasOne'])) {
            return $this;
        }

        // Iterate relationships
        foreach ($this->relationships['hasOne'] as $join) {
            $this->records = array_map(function ($record) use ($join) {
                foreach ($record as $key => $value) {
                    $prefix = '_' . $join['alias'] . '_';
                    if (preg_match('/^' . $prefix . '[\w]+/', $key)) {
                        $record[$join['alias']][str_replace($prefix, '', $key)] = $value;
                        unset($record[$key]);
                    }
                }
                return $record;
            }, $this->records);
        }

        // Return model instance
        return $this;
    }
private function formatHasOne ( ) { // Return if there are no relationships of that type if ( ! isset ( $ this -> relationships [ 'hasOne' ] ) || empty ( $ this -> relationships [ 'hasOne' ] ) ) { return $ this ; } // Iterate relationships foreach ( $ this -> relationships [ 'hasOne' ] as $ join ) { $ this -> records = array_map ( function ( $ record ) use ( $ join ) { foreach ( $ record as $ key => $ value ) { $ prefix = '_' . $ join [ 'alias' ] . '_' ; if ( preg_match ( '/^' . $ prefix . '[\w]+/' , $ key ) ) { $ record [ $ join [ 'alias' ] ] [ str_replace ( $ prefix , '' , $ key ) ] = $ value ; unset ( $ record [ $ key ] ) ; } } return $ record ; } , $ this -> records ) ; } // Return model instance return $ this ; }
Format has many relationships results

@return object Model instance
Format has many relationships results