src/HasRelationships.php
protected function hasOneOrManyDeepThroughParents(array $through)
    {
        return array_map(function ($class) {
            $segments = preg_split('/\s+as\s+/i', $class);

            $instance = Str::contains($segments[0], '\\')
                ? new $segments[0]
                : (new Pivot)->setTable($segments[0]);

            if (isset($segments[1])) {
                $instance->setTable($instance->getTable().' as '.$segments[1]);
            }

            return $instance;
        }, $through);
    }
protected function hasOneOrManyDeepThroughParents(array $through)
    {
        return array_map(function ($class) {
            $segments = preg_split('/\s+as\s+/i', $class);

            $instance = Str::contains($segments[0], '\\')
                ? new $segments[0]
                : (new Pivot)->setTable($segments[0]);

            if (isset($segments[1])) {
                $instance->setTable($instance->getTable().' as '.$segments[1]);
            }

            return $instance;
        }, $through);
    }
protected function hasOneOrManyDeepThroughParents ( array $ through ) { return array_map ( function ( $ class ) { $ segments = preg_split ( '/\s+as\s+/i' , $ class ) ; $ instance = Str :: contains ( $ segments [ 0 ] , '\\' ) ? new $ segments [ 0 ] : ( new Pivot ) -> setTable ( $ segments [ 0 ] ) ; if ( isset ( $ segments [ 1 ] ) ) { $ instance -> setTable ( $ instance -> getTable ( ) . ' as ' . $ segments [ 1 ] ) ; } return $ instance ; } , $ through ) ; }
Prepare the through parents for a has-one-deep or has-many-deep relationship.

@param  array  $through
@return array
Prepare the through parents for a has - one - deep or has - many - deep relationship .