mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Chages to x2Many relationships detection & adds relationship_count docBlock comment (#783)
* x to Many relationships are detected via a `Many` keyword in the relationship object class name * reason: example: `belongsTo` was incorrectly recognized as `belongsToMany` * adds `@property-read int|null $x2Many_relationship_method_name_count` model class docBlock comment * when model makes use of `withCount` or `loadCount` there is a property on the resource `$instance->relationship_method_count` that states the count of related models * can be `NULL` when `withCount` or `loadCount` aren't used
This commit is contained in:
committed by
Barry vd. Heuvel
parent
8ab6e0536b
commit
c9132b28a6
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user