Skip to content

Model methods are missing with --write-mixin #1343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
patrik-csak opened this issue Apr 19, 2022 · 1 comment · Fixed by #1352
Closed

Model methods are missing with --write-mixin #1343

patrik-csak opened this issue Apr 19, 2022 · 1 comment · Fixed by #1352
Labels

Comments

@patrik-csak
Copy link

Versions:

  • ide-helper Version: 2.12.3
  • Laravel Version: 9.9.0
  • PHP Version: 8.1.3

Description:

Model methods are missing when using --write-mixin

With --write-mixin Without --write-mixin

Basic model methods like find appear to be missing when using --write-mixin. They work correctly without --write-mixin

I've reproduced the following steps in this repo: https://github.com/ptrkcsk/laravel-ide-helper-models

There are two differences in _ide_helper_models.php between using --write-mixin and not, as seen here: https://github.com/ptrkcsk/laravel-ide-helper-models/compare/write-mixin...no-write-mixin

  1. The generated class has @mixin IdeHelperUser. This looks like a mistake to me because IdeHelperUser appears to not exist
  2. The generated class extends \Eloquent. I suspect this is the problem, because with --write-mixin, the generated class is missing the methods provided by \Eloquent

Steps To Reproduce:

  1. Generate facades helper and models helper with --write-mixin:

    vendor/bin/sail artisan ide-helper:generate
    vendor/bin/sail artisan ide-helper:models --write-mixin
  2. Try to use a model's find method, e.g. User::find(). Notice "Method 'find' not found..." warning in IDE

  3. Re-generate models helper without --write-mixin:

    vendor/bin/sail artisan ide-helper:models
  4. Try to use a model's find method again. Notice find method is now found

@abelharisov
Copy link

I faced with the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants