laravel-ide-helper
laravel-ide-helper copied to clipboard
"Extended" relationships fails to be recognized
Versions:
- ide-helper Version: 2,12,3
- Laravel Version: 9.19.0
- PHP Version: 8.0.2
Description:
When we "extend# an existing relationship, ide-helper seems to ignore this new relationship.
Let's say we have a relationship like:
public function allocatedAssets(): HasManyThrough|AllocatedAsset
{
return $this->hasManyThrough(
AllocatedAsset::class,
Allocation::class,
);
}
We want to get only the "open" ones (some filter on the existing relationship):
public function openAllocatedAssets(): HasManyThrough|AllocatedAsset
{
return $this->allocatedAssets()
->where(fn($query) => $query->whereNull('arrived_at')->where('will_not_arrive', false));
}
The above code will not generate the expected docblock lines:
/**
* @property-read Collection|AllocatedAsset[] $openAllocatedAssets
* @property-read int|null $open_allocated_assets_count
*/
This way it works:
public function openAllocatedAssets(): HasManyThrough|AllocatedAsset
{
return $this->hasManyThrough(
AllocatedAsset::class,
Allocation::class,
)
->where(fn($query) => $query->whereNull('arrived_at')->where('will_not_arrive', false));
}