public function __call($method, $args)
{
$scopes = $this->mapper()->scopes();
// Custom methods
if (isset(self::$_customMethods[$method]) && is_callable(self::$_customMethods[$method])) {
$callback = self::$_customMethods[$method];
// Pass the current query object as the first parameter
array_unshift($args, $this);
return call_user_func_array($callback, $args);
// Scopes
} elseif (isset($scopes[$method])) {
// Pass the current query object as the first parameter
array_unshift($args, $this);
return call_user_func_array($scopes[$method], $args);
// Methods on Collection
} elseif (method_exists('\\Spot\\Entity\\Collection', $method)) {
return call_user_func_array([$this->execute(), $method], $args);
// Error
} else {
throw new \BadMethodCallException("Method '" . __CLASS__ . "::" . $method . "' not found");
}
}