Phalcon\Mvc\Model\EagerLoading\Loader::addEagerLoad PHP Method

addEagerLoad() public method

public addEagerLoad ( string $relationAlias, null | callable $constraints = null )
$relationAlias string
$constraints null | callable
    public function addEagerLoad($relationAlias, $constraints = null)
    {
        if (!is_string($relationAlias)) {
            throw new \InvalidArgumentException(sprintf('$relationAlias expects to be a string, `%s` given', gettype($relationAlias)));
        }
        if ($constraints !== null && !is_callable($constraints)) {
            throw new \InvalidArgumentException(sprintf('$constraints expects to be a callable, `%s` given', gettype($constraints)));
        }
        $this->eagerLoads[$relationAlias] = $constraints;
        return $this;
    }