barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.17k stars 1.16k forks source link

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

Open func0der opened 8 months ago

func0der commented 8 months ago

Versions:

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:

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 ;)