protected function maxDepthFromRelations(array $relations)
    {

        if (!$relations) {
            return 1;
        }

        $max = 1;

        foreach ($relations as $path) {
            $max = max($max, count(explode('.', $path)));
        }

        // max has to be relation depth +1 because we want to have the
        // keys of that relation too
        return (int)$max + 1;

    }
protected function maxDepthFromRelations(array $relations)
    {

        if (!$relations) {
            return 1;
        }

        $max = 1;

        foreach ($relations as $path) {
            $max = max($max, count(explode('.', $path)));
        }

        // max has to be relation depth +1 because we want to have the
        // keys of that relation too
        return (int)$max + 1;

    }
protected function maxDepthFromRelations ( array $ relations ) { if ( ! $ relations ) { return 1 ; } $ max = 1 ; foreach ( $ relations as $ path ) { $ max = max ( $ max , count ( explode ( '.' , $ path ) ) ) ; } // max has to be relation depth +1 because we want to have the // keys of that relation too return ( int ) $ max + 1 ; }
Calculate the max depth from the passed relations

@param array $relations

@return int
Calculate the max depth from the passed relations