Open BoyeMagnus opened 4 years ago
The same applies for hinting within scopes. (Can't type hint a scope method within a scope (even if in the same model))
(scopeWhereInInterval exists on the same model, as that scope is being declared in)
Just found out, that this is related to https://github.com/laravel-idea/plugin/issues/45 However could this not be done without doc blocks?
Hi, Magnus. Have you generated helper code by "Generate Eloquent Helper Code" code generation? It should at least help in the first case. About completing inside scopes... It's possible. I'll try.
I've just been using the "barryvdh/laravel-ide-helper" package for generating the annotations.
The reason why it's not finding it on the first, is because I didn't write return annotations. (The IDE think it's a hasMany model, and can't typehint).
Both of the typehinting is available if dirty typehinting is used. The hasmany followed by a scope:
The nested scope: However this wont work, if another where is used before it (the where returns a builder instance, which the IDE will try to typehint)
Hope this helps :)
Would be nice, if we could skip the Builder|MODELNAME annotation at all! Because some of the places you're not able to really edit the annotation (such as the nested scope)
Would be nice, if we could skip the Builder|MODELNAME annotation at all!
"Generate Eloquent Helper Code" fixes this problem. Also, it generates some pseudo-classes, like "_ShiftQueryBuilder" and I can only programmatically add this "type" to $query variable. This should add all these scope and other methods to completion.
"Generate Eloquent Helper Code" fixed the problem 💯 Would it be possible to link to the correct method (on cmd+click), instead of the helper file?
The nested scope still has problems: (as you mentioned)
Would it be possible to link to the correct method (on cmd+click), instead of the helper file?
It should be already fixed in PhpStorm 2020.2.
The nested scope still has problems: (as you mentioned)
I'll try to fix that.
Hi I've been testing the plugin out for some time now, and have an idea for a nice improvement: There is missing hinting on scopes for relationships. Here I've got a user with a hasMany relation (shifts). The onGoingOrGreaterThanNow scope (on the shift) is not type hinted. (the whereNull value is hintable by the plugin 🥇 )
The user model: (no php doc blocks)
The shift scope:
Hope it makes sense, and is something that is durable to fix :)