mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-20 02:53:11 +00:00
Check if the class is a model before instantiating
This commit is contained in:
@@ -146,6 +146,9 @@ class ModelsCommand extends Command {
|
|||||||
$reflectionClass = new \ReflectionClass($name);
|
$reflectionClass = new \ReflectionClass($name);
|
||||||
if (!$reflectionClass->IsInstantiable()) {
|
if (!$reflectionClass->IsInstantiable()) {
|
||||||
throw new \Exception($name . ' is not instanciable.');
|
throw new \Exception($name . ' is not instanciable.');
|
||||||
|
}elseif(!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model')){
|
||||||
|
$this->comment("Class '$name' is not a model");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$model = new $name();
|
$model = new $name();
|
||||||
|
|||||||
Reference in New Issue
Block a user