diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 9c3ccbe..a07ed07 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -503,7 +503,7 @@ class ModelsCommand extends Command 'morphToMany', 'morphedByMany', ]; - if (in_array($relation, $relations)) { + if (strpos(get_class($relationObj), 'Many') !== false) { //Collection or array of models (because Collection is Arrayable) $this->setProperty( $method, @@ -511,6 +511,12 @@ class ModelsCommand extends Command true, null ); + $this->setProperty( + Str::snake($method) . '_count', + 'int|null', + true, + false + ); } elseif ($relation === "morphTo") { // Model isn't specified because relation is polymorphic $this->setProperty(