Mongolid\ActiveRecord::__call PHP Method

__call() public method

Handle dynamic method calls into the model.
public __call ( mixed $method, mixed $parameters ) : mixed
$method mixed Name of the method that is being called.
$parameters mixed Parameters of $method.
return mixed
    public function __call($method, $parameters)
    {
        $value = $parameters[0] ?? null;
        // Alias to attach
        if ('attachTo' == substr($method, 0, 8)) {
            $field = lcfirst(substr($method, 8));
            return $this->attach($field, $value);
        }
        // Alias to embed
        if ('embedTo' == substr($method, 0, 7)) {
            $field = lcfirst(substr($method, 7));
            return $this->embed($field, $value);
        }
        throw new BadMethodCallException(sprintf('The following method can not be reached or does not exist: %s@%s', get_class($this), $method));
    }