laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Model methods are missing with `--write-mixin`

Open patrik-csak opened this issue 3 years ago • 1 comments

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

patrik-csak avatar Apr 19 '22 17:04 patrik-csak

I faced with the same issue

abelharisov avatar Apr 19 '22 19:04 abelharisov