protected function getFieldsForRelationPath($fields, $relationPath) {
        if ('*' == $fields) {
            return '*';
        }

        if (is_array($fields)) { // only implemented for arrays for now
            $final = [];
            foreach ($fields as $column => $as) {
                $cName = is_numeric($column) ? $as : $column;
                if (($relationPath . '.') == substr($cName, 0, strlen($relationPath) + 1)) {
                    $cName = substr($cName, strlen($relationPath) + 1);
                    if (is_numeric($column)) {
                        $final[] = $cName;
                    } else {
                        $final[$cName] = $as;
                    }
                }
            }
            return $final;
        }

        return '*';
    }
protected function getFieldsForRelationPath($fields, $relationPath) {
        if ('*' == $fields) {
            return '*';
        }

        if (is_array($fields)) { // only implemented for arrays for now
            $final = [];
            foreach ($fields as $column => $as) {
                $cName = is_numeric($column) ? $as : $column;
                if (($relationPath . '.') == substr($cName, 0, strlen($relationPath) + 1)) {
                    $cName = substr($cName, strlen($relationPath) + 1);
                    if (is_numeric($column)) {
                        $final[] = $cName;
                    } else {
                        $final[$cName] = $as;
                    }
                }
            }
            return $final;
        }

        return '*';
    }
protected function getFieldsForRelationPath ( $ fields , $ relationPath ) { if ( '*' == $ fields ) { return '*' ; } if ( is_array ( $ fields ) ) { // only implemented for arrays for now $ final = [ ] ; foreach ( $ fields as $ column => $ as ) { $ cName = is_numeric ( $ column ) ? $ as : $ column ; if ( ( $ relationPath . '.' ) == substr ( $ cName , 0 , strlen ( $ relationPath ) + 1 ) ) { $ cName = substr ( $ cName , strlen ( $ relationPath ) + 1 ) ; if ( is_numeric ( $ column ) ) { $ final [ ] = $ cName ; } else { $ final [ $ cName ] = $ as ; } } } return $ final ; } return '*' ; }
Extracts only fields required for this relations
@param $fields
@param $relationPath
@return array|string
Extracts only fields required for this relations