mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-17 17:47:13 +00:00
resolve namespaces
This commit is contained in:
@@ -671,6 +671,8 @@ class ModelsCommand extends Command
|
||||
$begin = strpos($code, 'function(');
|
||||
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
|
||||
|
||||
$customPivots = [];
|
||||
|
||||
foreach (
|
||||
$this->getRelationTypes() as $relation => $impl
|
||||
) {
|
||||
@@ -716,20 +718,11 @@ class ModelsCommand extends Command
|
||||
if (!in_array($pivot, [Pivot::class, MorphPivot::class])) {
|
||||
$pivot = $this->getClassNameInDestinationFile($model, $pivot);
|
||||
|
||||
if ($existingPivot = ($this->properties[$relationObj->getPivotAccessor()] ?? null)) {
|
||||
// If the pivot is already set, we need to append the type to it
|
||||
$pivot .= '|' . $existingPivot['type'];
|
||||
if(isset($customPivots[$relationObj->getPivotAccessor()])){
|
||||
$customPivots[$relationObj->getPivotAccessor()][] = $pivot;
|
||||
} else {
|
||||
// pivots are not always set
|
||||
$pivot .= '|null';
|
||||
$customPivots[$relationObj->getPivotAccessor()] = [$pivot];
|
||||
}
|
||||
|
||||
$this->setProperty(
|
||||
$relationObj->getPivotAccessor(),
|
||||
$this->getClassNameInDestinationFile($model, $pivot),
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -787,6 +780,15 @@ class ModelsCommand extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($customPivots as $pivotAccessor => $pivots){
|
||||
$this->setProperty(
|
||||
$pivotAccessor,
|
||||
implode('|', $pivots) . '|null',
|
||||
true,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @property-read \DifferentCustomPivot|\CustomPivot|null $pivot
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationCustomPivotUsingSameAccessor
|
||||
* @property-read int|null $relation_custom_pivot_using_same_accessor_count
|
||||
* @property-read \CustomPivot|null $customAccessor
|
||||
* @property-read DifferentCustomPivot|null $pivot
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithCustomPivot
|
||||
* @property-read int|null $relation_with_custom_pivot_count
|
||||
* @property-read \DifferentCustomPivot|null $differentCustomAccessor
|
||||
* @property-read CustomPivot|null $customAccessor
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithDifferentCustomPivot
|
||||
* @property-read int|null $relation_with_different_custom_pivot_count
|
||||
* @property-read DifferentCustomPivot|null $differentCustomAccessor
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithDifferentCustomPivotUsingSameAccessor
|
||||
* @property-read int|null $relation_with_different_custom_pivot_using_same_accessor_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot newModelQuery()
|
||||
|
||||
Reference in New Issue
Block a user