Open MatanYadaev opened 3 years ago
@KaloyanYosifov Any idea how to implement it?
I guess this one is going to be a tough one to crack.
I guess we can generate a class in PostsHasMany
that extends HasMany
and add it as a return type in the doc block of the relationship method. But if you have a type hint on the method already it will break. That is just what I am assuming on a first glance.
Will check out it out on the weekend, if no one else does it first.
Wish you a great week @MatanYadaev 🙌
@barryvdh Do you think this feature is feasible?
Can you tell PHPStorm that $user->posts()
is HasMany
that extends PostBuilder
?
A month ago this package began to support dedicated builders https://github.com/barryvdh/laravel-ide-helper/pull/1089
It will be extremely powerful if the dedicated builders support will be applied to relationships as well.
PHPStorm and static analysis tools know that
$user->posts()
returns aHasMany
instance, and because of this they throw an error for this piece of code:The solution is to somehow add a
@mixin PostBuilder
to this specificHasMany
instance.