From 5318f485e23983c69a7ae3fa39e2d078bcdee4b1 Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Fri, 7 Sep 2018 10:27:20 +0200 Subject: [PATCH 1/2] Add ::query support --- src/Console/ModelsCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index d3fdfd8..3e15915 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -409,6 +409,7 @@ class ModelsCommand extends Command protected function getPropertiesFromMethods($model) { $methods = get_class_methods($model); + if ($methods) { sort($methods); foreach ($methods as $method) { @@ -444,6 +445,9 @@ class ModelsCommand extends Command array_shift($args); $this->setMethod($name, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->class, $args); } + } elseif (in_array($method, ['query', 'newQuery', 'newModelQuery'])) { + $reflection = new \ReflectionClass($model); + $this->setMethod($method, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->getName()); } elseif (!method_exists('Illuminate\Database\Eloquent\Model', $method) && !Str::startsWith($method, 'get') ) { From e7d4cb322fb370c4f2d06292c6a22202f8b32149 Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Fri, 7 Sep 2018 10:29:59 +0200 Subject: [PATCH 2/2] Update ModelsCommand.php --- src/Console/ModelsCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 3e15915..306c176 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -409,7 +409,6 @@ class ModelsCommand extends Command protected function getPropertiesFromMethods($model) { $methods = get_class_methods($model); - if ($methods) { sort($methods); foreach ($methods as $method) {