Compare commits

...
21 Commits
Author SHA1 Message Date
Barry vd. Heuvel 19553f63e4 Update composer.json 2016-03-02 11:03:09 +01:00
Barry vd. Heuvel f50470ba49 Add morphOne, fix morphTo
Fixes #236 thanks to @boxfrommars
2016-03-02 10:54:41 +01:00
Barry vd. Heuvel 7762e07f0a Use new provider config
Fixes #274, #324
2016-03-02 10:47:25 +01:00
Barry vd. Heuvel 467b5f5b5f Always add whereColumn
Fixes #300, #325
2016-03-02 10:42:37 +01:00
Barry vd. Heuvel c213be3d3c Merge pull request #305 from matiaspub/patch-1
Add extend \Eloquent for ide-helper:models command
2016-03-02 10:39:21 +01:00
Barry vd. Heuvel 4b8ba85b34 Merge pull request #315 from icedfish/ignore_exception
Ignore abstract class or interface, not throw exception
2016-01-28 09:19:58 +01:00
Barry vd. Heuvel d4c0ae5851 Merge pull request #314 from icedfish/recover-helper-function
recover model's whereXXX() helper function
2016-01-28 07:21:05 +01:00
Yu Bing 3a01e351de Ignore abstract class or interface, not throw exception 2016-01-28 11:37:08 +08:00
Yu Bing add34665a8 fix typo 2016-01-28 11:20:48 +08:00
Yu Bing c77752bb58 recover model's whereXXX() helper function 2016-01-28 11:18:42 +08:00
Barry vd. Heuvel aa8f772a46 Merge pull request #310 from naerymdan/master
Add support for Lumen 5.0, 5.1 and 5.2+
2016-01-22 14:33:15 +01:00
Vincent Labreche 0c4c55f349 Add support for Lumen 5.0, 5.1 and 5.2+ 2016-01-22 08:30:36 -05:00
Barry vd. Heuvel ed972acf19 Merge pull request #308 from barryvdh/revert-303-master
Revert "Don't use force aliases loading"
2016-01-21 15:55:37 +01:00
Barry vd. Heuvel 60e642e881 Revert "Don't use force aliases loading" 2016-01-21 15:55:29 +01:00
Sergius 4069863d0c Add extend \Eloquent for ide-helper:models command
It's help author to close many issues! )
Like: #269, #259, #248, #209, #191, #74, 
and https://github.com/laravel/framework/issues/7558 )))
etc. maybe
2016-01-12 15:33:05 +02:00
Barry vd. Heuvel da05897cb7 Merge pull request #303 from dkulyk/master
Don't use force aliases loading
2016-01-11 13:00:09 +01:00
Dmytro Kulyk 74bac1a4e9 Don't use force aliases loading
Another autoloader throw exception if aliases not exists.
2016-01-11 13:45:41 +02:00
Barry vd. Heuvel 33cee80609 Merge pull request #302 from Propaganistas/patch-1
Fix Auth driver detection in Laravel 5.2
2016-01-08 18:03:38 +01:00
Propaganistas dee3878566 Fix Auth driver detection in Laravel 5.2 2016-01-06 20:31:08 +01:00
Barry vd. Heuvel eb5736a7bd Merge pull request #298 from onigoetz/patch-1
Allow symfony/class-loader 3.0 to be installed
2016-01-03 11:48:37 +01:00
Stéphane Goetz cc794a2fba Allow symfony/class-loader 3.0 to be installed 2016-01-03 11:25:12 +01:00
3 changed files with 24 additions and 6 deletions
+2 -2
View File
@@ -14,8 +14,8 @@
"illuminate/support": "5.0.x|5.1.x|5.2.x", "illuminate/support": "5.0.x|5.1.x|5.2.x",
"illuminate/console": "5.0.x|5.1.x|5.2.x", "illuminate/console": "5.0.x|5.1.x|5.2.x",
"illuminate/filesystem": "5.0.x|5.1.x|5.2.x", "illuminate/filesystem": "5.0.x|5.1.x|5.2.x",
"phpdocumentor/reflection-docblock": "2.0.4", "phpdocumentor/reflection-docblock": "^2.0.4",
"symfony/class-loader": "~2.3" "symfony/class-loader": "~2.3|~3.0"
}, },
"require-dev": { "require-dev": {
"doctrine/dbal": "~2.3" "doctrine/dbal": "~2.3"
+12 -2
View File
@@ -184,7 +184,8 @@ class ModelsCommand extends Command
} }
if (!$reflectionClass->IsInstantiable()) { if (!$reflectionClass->IsInstantiable()) {
throw new \Exception($name . ' is not instantiable.'); // ignore abstract class or interface
continue;
} }
$model = $this->laravel->make($name); $model = $this->laravel->make($name);
@@ -290,6 +291,7 @@ class ModelsCommand extends Command
$comment = $column->getComment(); $comment = $column->getComment();
$this->setProperty($name, $type, true, true, $comment); $this->setProperty($name, $type, true, true, $comment);
$this->setMethod(Str::camel("where_" . $name), '\Illuminate\Database\Query\Builder|\\' . get_class($model), array('$value'));
} }
} }
} }
@@ -354,6 +356,7 @@ class ModelsCommand extends Command
'belongsToMany', 'belongsToMany',
'hasOne', 'hasOne',
'belongsTo', 'belongsTo',
'morphOne',
'morphTo', 'morphTo',
'morphMany', 'morphMany',
'morphToMany' 'morphToMany'
@@ -375,6 +378,9 @@ class ModelsCommand extends Command
true, true,
null null
); );
} elseif ($relation === "morphTo") {
// Model isn't specified because relation is polymorphic
$this->setProperty($method, '\Illuminate\Database\Eloquent\Model|\Eloquent', true, null);
} else { } else {
//Single model is returned //Single model is returned
$this->setProperty($method, $relatedModel, true, null); $this->setProperty($method, $relatedModel, true, null);
@@ -484,6 +490,10 @@ class ModelsCommand extends Command
$phpdoc->appendTag($tag); $phpdoc->appendTag($tag);
} }
if ($this->write) {
$phpdoc->appendTag(Tag::createInstance("@mixin \\Eloquent", $phpdoc));
}
$serializer = new DocBlockSerializer(); $serializer = new DocBlockSerializer();
$serializer->getDocComment($phpdoc); $serializer->getDocComment($phpdoc);
$docComment = $serializer->getDocComment($phpdoc); $docComment = $serializer->getDocComment($phpdoc);
@@ -507,7 +517,7 @@ class ModelsCommand extends Command
} }
} }
$output = "namespace {$namespace}{\n{$docComment}\n\tclass {$classname} {}\n}\n\n"; $output = "namespace {$namespace}{\n{$docComment}\n\tclass {$classname} extends \Eloquent {}\n}\n\n";
return $output; return $output;
} }
+10 -2
View File
@@ -12,6 +12,7 @@ namespace Barryvdh\LaravelIdeHelper;
use Illuminate\Foundation\AliasLoader; use Illuminate\Foundation\AliasLoader;
use Illuminate\Config\Repository as ConfigRepository; use Illuminate\Config\Repository as ConfigRepository;
use ReflectionClass;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class Generator class Generator
@@ -113,11 +114,18 @@ class Generator
protected function detectDrivers() protected function detectDrivers()
{ {
$this->interfaces['\Illuminate\Contracts\Auth\Authenticatable'] = config('auth.model', 'App\User'); $this->interfaces['\Illuminate\Contracts\Auth\Authenticatable'] = config('auth.providers.users.model', config('auth.model', 'App\User'));
try{ try{
if (class_exists('Auth') && is_a('Auth', '\Illuminate\Support\Facades\Auth', true)) { if (class_exists('Auth') && is_a('Auth', '\Illuminate\Support\Facades\Auth', true)) {
$class = get_class(\Auth::driver()); if (class_exists('\Illuminate\Foundation\Application')) {
$authMethod = version_compare(\Illuminate\Foundation\Application::VERSION, '5.2', '>=') ? 'guard' : 'driver';
} else {
$refClass = new ReflectionClass('\Laravel\Lumen\Application');
$versionStr = $refClass->newInstanceWithoutConstructor()->version();
$authMethod = strpos($versionStr, 'Lumen (5.0') === 0 ? 'driver' : (strpos($versionStr, 'Lumen (5.1') === 0 ? 'driver' : 'guard');
}
$class = get_class(\Auth::$authMethod());
$this->extra['Auth'] = array($class); $this->extra['Auth'] = array($class);
$this->interfaces['\Illuminate\Auth\UserProviderInterface'] = $class; $this->interfaces['\Illuminate\Auth\UserProviderInterface'] = $class;
} }