Git Product home page Git Product logo

Comments (6)

barryvdh avatar barryvdh commented on August 19, 2024

That looks useful indeed. Will see when I have some extra time.
Of you want you can also submit a PR.

from laravel-ide-helper.

barryvdh avatar barryvdh commented on August 19, 2024

Pushed an update, does this work for you?

from laravel-ide-helper.

hailwood avatar hailwood commented on August 19, 2024

It almost does, although instead of just marking the return type as \WhateverModel it should probably be \Illuminate\Database\Query\Builder|\WhateverModel otherwise using e.g.

\WhateverModel::whereName('admin')->first() 

ends up marking first() as an undefined method.

from laravel-ide-helper.

barryvdh avatar barryvdh commented on August 19, 2024

But doesnt eloquent already extend that class? (in the helper at least)

from laravel-ide-helper.

barryvdh avatar barryvdh commented on August 19, 2024

For me, User::whereEmail('..') returns an User instance. User extends Eloquent (the facade) and the ide_helper.php adds the first() etc methods to Eloquent.
Did you also generate the ide helper file? And do you extend Eloquent, or Illuminate\Database\Eloquent\Model? Only extending Eloquent works with the helper, not the Model class directly.

from laravel-ide-helper.

hailwood avatar hailwood commented on August 19, 2024

You are correct it does, but for users like (for now) myself who use packages like ardent our models extend PackageModelX which extends Eloquent, but because PackageModelX is a package model the ide-helper does not know about those, hence the chain gets broken, which is why adding \Illuminate\Database\Query\Builder fixes it for me!

from laravel-ide-helper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.