plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Bug]: No Autocomplete on whereHas Polymorphic Relationship

Open gradedcatfood opened this issue 4 years ago • 1 comments

Bug description

Hello,

I'm not getting autocompletion on column names within a whereHas on a polymorphic relationship. The code works fine, but phpstorm is only trying to autocomplete columns on the tags table. I expected it to try and autocomplete columns on the taggables table, but maybe I'm wrong in assuming so.

I'm generating helper files from the plugin not via the barry ide helper package.

Here is the code:

$runs = Run::query()
    ->whereRelation('user', 'id', Auth::user()->id)
    ->whereHas('tags', function (Builder $query) use ($tagIds) {
        $query->whereIn('tag_id', $tagIds); // tag_id is not auto completing
    })
    ->with('tags')
    ->get();

I will however get autocompletion for columns that exist on the tags table (please see "where has autocomplete on tags table" screenshot)

Please let me know if I can provide more information or if I'm wrong in assuming that the taggables table columns would not expect to autocomplete.

Sorry for the bombarding of photos but I just want to post all the models/relationships involved Tag model Run Model taggables table tags table where has autocomplete on tags table where has no automcplete on taggables table

Plugin version

4.4.3.212

Operating system

MacOS

Steps to reproduce

No response

Relevant log output

No response

gradedcatfood avatar Nov 09 '21 16:11 gradedcatfood

Hi, Michael. Yes, Laravel Idea doesn't understand morph relations very well. We will try to improve this. Thanks for "bombarding of photos". They explain the issue very clear :)

adelf avatar Dec 04 '21 12:12 adelf