Laravel-ide-helper: hasMany on model

Created on 4 Mar 2016  路  5Comments  路  Source: barryvdh/laravel-ide-helper

If I have a relationship defined on a model, e.g.

class Person extends \Eloquent
{
    public function address()
    {
        return $this->hasMany('App\Addresss');
    }
}

I should be able to autocomplete $person->address()->where(... but it doesn't come up. The address() function returns \Illuminate\Database\Eloquent\Relations\HasMany.

Most helpful comment

I created a standalone file supplement to ide-helper, hope it helps you.

https://gist.github.com/zhwei/f13ea35b157d4b8687118e6b40ff30b7

Maintained by Human and Sublime.

All 5 comments

You can change the phpdocs for that function if you want.

Ah, OK. So @return Illuminate\Database\Eloquent\Relations\HasMany|Illuminate\Database\Query\Builder seems to work. I think I'm now finding IDE issues, rather than issues with your helper. Thanks!

I could be interesting to change the phpdocs for the methods, but not sure if that is the best way. It would be best fixed in the core..

I created a standalone file supplement to ide-helper, hope it helps you.

https://gist.github.com/zhwei/f13ea35b157d4b8687118e6b40ff30b7

Maintained by Human and Sublime.

@barryvdh tested locally, this works correctly nowadays without any manual work; I vote for closing :}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

beniaminorossini picture beniaminorossini  路  5Comments

quantumwebco picture quantumwebco  路  4Comments

andrew-svirin picture andrew-svirin  路  4Comments

neeravp picture neeravp  路  3Comments

Alymosul picture Alymosul  路  4Comments