public function with($relations)
    {
        if (is_array($relations)) {
            if (Arr::isAssoc($relations)) {
                $relations = array_keys($relations);
            }

            $this->eagerLoads = array_merge($this->eagerLoads, $relations);
        }

        if (is_string($relations)) {
            if (Str::contains($relations, '.')) {
                $relations = explode('.', $relations)[0];
            }

            if (Str::contains($relations, ':')) {
                $relations = explode(':', $relations)[0];
            }

            if (in_array($relations, $this->eagerLoads)) {
                return $this;
            }

            $this->eagerLoads[] = $relations;
        }

        return $this->__call('with', (array) $relations);
    }
public function with($relations)
    {
        if (is_array($relations)) {
            if (Arr::isAssoc($relations)) {
                $relations = array_keys($relations);
            }

            $this->eagerLoads = array_merge($this->eagerLoads, $relations);
        }

        if (is_string($relations)) {
            if (Str::contains($relations, '.')) {
                $relations = explode('.', $relations)[0];
            }

            if (Str::contains($relations, ':')) {
                $relations = explode(':', $relations)[0];
            }

            if (in_array($relations, $this->eagerLoads)) {
                return $this;
            }

            $this->eagerLoads[] = $relations;
        }

        return $this->__call('with', (array) $relations);
    }
public function with ( $ relations ) { if ( is_array ( $ relations ) ) { if ( Arr :: isAssoc ( $ relations ) ) { $ relations = array_keys ( $ relations ) ; } $ this -> eagerLoads = array_merge ( $ this -> eagerLoads , $ relations ) ; } if ( is_string ( $ relations ) ) { if ( Str :: contains ( $ relations , '.' ) ) { $ relations = explode ( '.' , $ relations ) [ 0 ] ; } if ( Str :: contains ( $ relations , ':' ) ) { $ relations = explode ( ':' , $ relations ) [ 0 ] ; } if ( in_array ( $ relations , $ this -> eagerLoads ) ) { return $ this ; } $ this -> eagerLoads [ ] = $ relations ; } return $ this -> __call ( 'with' , ( array ) $ relations ) ; }
Set the relationships that should be eager loaded.

@param mixed $relations

@return $this|Model
Set the relationships that should be eager loaded .