Skip to content
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

Models that have static::$snakeAttributes set to true should use attribute names without case conversion #1500

Open
func0der opened this issue Jan 24, 2024 · 0 comments
Labels

Comments

@func0der
Copy link

Versions:

  • ide-helper Version: master
  • Laravel Version: 10.17.1
  • PHP Version: 8.1

Description:

If I understand the code in \Illuminate\Database\Eloquent\Concerns\HasAttributes that relies on the \Illuminate\Database\Eloquent\Concerns\HasAttributes::$snakeAttributes property correctly, the column namens coming from the database are used untouched as attributes in the models have set $snakeAttributes = false.

So column fooBar will be attribute fooBar and column foo_bar will become attribute foo_bar.

In the config we have the variable model_camel_case_properties which can be used to configure the behavior of the ide helper during generation of model php docs.
It is as document an "all or nothing" approach.

Instead of that, could we just see in the models, which as far as I understand are reflected and inspected anyway, check for that $snakeAttributes property being set to false and let the ide helper generate the PHPDoc accordingly?

Steps To Reproduce:

  • Have a model with $snakeAttributes = false
  • Have a database column on that model in camelCase
  • Have a database column on that model in snake_case
  • Generate model docs

Should be something along the lines:

 * @property string $camelCase
 * @property string $snake_case

What do you think?

I am fairly new to Laravel, Eloquent and the sorts, so I appreciate any new insights you can give me into this :)

P.S.: Thanks for your awesome work ;)

@func0der func0der added the bug label Jan 24, 2024
@func0der func0der changed the title Models that have static::$snakeAttributes set to true should use properties as is Models that have static::$snakeAttributes set to true should use attribute names without case conversion Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant