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