From 843fbc04c434729d8a90ecf1e8c002820e97ee01 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sat, 27 Apr 2013 20:17:29 +0200 Subject: [PATCH] Extend eloquent from Query Builder Fixes #6 Eloquent doesn't have the where() methods, and other query methods, but resolves them with __call(). Extending the Builder class seems the most appropriate solution. --- src/Barryvdh/LaravelIdeHelper/GeneratorCommand.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Barryvdh/LaravelIdeHelper/GeneratorCommand.php b/src/Barryvdh/LaravelIdeHelper/GeneratorCommand.php index a216e9c..77d34d0 100644 --- a/src/Barryvdh/LaravelIdeHelper/GeneratorCommand.php +++ b/src/Barryvdh/LaravelIdeHelper/GeneratorCommand.php @@ -104,7 +104,9 @@ class GeneratorCommand extends Command { $output = "getAliases() as $alias => $facade){ + $aliases = $aliasLoader->getAliases(); + $aliases += array('QueryBuilder' => "Illuminate\Database\Query\Builder"); + foreach($aliases as $alias => $facade){ try{ if(method_exists($facade, 'getFacadeRoot')){ @@ -142,8 +144,10 @@ class GeneratorCommand extends Command { $output .= "namespace $namespace {\n"; - //If the root class is not the same as the facade extend it. - if($root !== $facade || in_array($alias, $onlyExtend)){ + if($alias == "Eloquent"){ + $output .= " class $alias extends QueryBuilder{\n"; + }elseif($root !== $facade || in_array($alias, $onlyExtend)){ + //If the root class is not the same as the facade extend it. $output .= " class $alias extends $facade{\n"; }else{ $output .= " class $alias{\n";