Skip to content
Permalink
Browse files

formatting and fix bug

  • Loading branch information
taylorotwell committed Jan 2, 2020
1 parent 943b23c commit 28fa74e8222a57118ae1b590101a35f63b964f81
Showing with 23 additions and 15 deletions.
  1. +23 −15 src/Illuminate/Database/Eloquent/Builder.php
@@ -1375,21 +1375,7 @@ public static function __callStatic($method, $parameters)
}

if ($method === 'mixin') {
$mixin = $parameters[0];
$replace = $parameters[1] ?? true;

$methods = (new ReflectionClass($mixin))->getMethods(
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
);

foreach ($methods as $method) {
if ($replace || ! static::hasMacro($method->name)) {
$method->setAccessible(true);
static::macro($method->name, $method->invoke($mixin));
}
}

return;
return static::registerMixin($parameters[0], $parameters[1] ?? true);
}

if (! static::hasGlobalMacro($method)) {
@@ -1403,6 +1389,28 @@ public static function __callStatic($method, $parameters)
return call_user_func_array(static::$macros[$method], $parameters);
}

/**
* Register the given mixin with the builder.
*
* @param string $mixin
* @param bool $replace
* @return void
*/
protected static function registerMixin($mixin, $replace)
{
$methods = (new ReflectionClass($mixin))->getMethods(
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
);

foreach ($methods as $method) {
if ($replace || ! static::hasGlobalMacro($method->name)) {
$method->setAccessible(true);

static::macro($method->name, $method->invoke($mixin));
}
}
}

/**
* Force a clone of the underlying query builder when cloning.
*

0 comments on commit 28fa74e

Please sign in to comment.
You can’t perform that action at this time.