laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
173 stars 7 forks source link

[Bug]: No Autocomplete on whereHas Polymorphic Relationship #438

Open mmillis1 opened 2 years ago

mmillis1 commented 2 years ago

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

adelf commented 2 years ago

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 :)