Illuminate\Database\Eloquent\Builder::nestedRelations PHP Method

nestedRelations() protected method

Get the deeply nested relations for a given top-level relation.
protected nestedRelations ( string $relation ) : array
$relation string
return array
    protected function nestedRelations($relation)
    {
        $nested = [];
        // We are basically looking for any relationships that are nested deeper than
        // the given top-level relationship. We will just check for any relations
        // that start with the given top relations and adds them to our arrays.
        foreach ($this->eagerLoad as $name => $constraints) {
            if ($this->isNested($name, $relation)) {
                $nested[substr($name, strlen($relation . '.'))] = $constraints;
            }
        }
        return $nested;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Get the deeply nested relations for a given top-level relation.
  *
  * @param string $relation
  * @return array 
  * @static 
  */
 public static function nestedRelations($relation)
 {
     return \Illuminate\Database\Eloquent\Builder::nestedRelations($relation);
 }