-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Fluent orderBy doesn't convert camelCase to snake_case #391
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
Comments
Sad to say this, but this whole camel-casing thing is really turning into a mess. |
👍 @franzliedke. I've set up email notifications for Laravel so I can check out PRs and issues. Half of them seem to be somehow related to snake / camel casing. It's getting pretty annoying. I don't get how converting to snake case makes things any better (not that it bothers me, I use snake case anyway...). Could we please have your input on this @taylorotwell ? |
Yup, I'd rather strip out the feature and let users deal with it themselves, this is getting out of hand in my opinion. |
PSR-0 only defines that the 'PHP' bits are camel case. In this case it's a string which would be correct if using camel case columns in the DB. |
@alexwhitman It's not about what needs to be camelCase or snake_case, but rather the consistency with which the snake_case to camelCase transformations are applied in cohesive behaviors. If I can treat last_name as if it were lastName in object accessors and model assignment then I should be able to do it in fluent methods also... |
That's certainly true but getters/setters are a different issue from your original example of |
@alexwhitman you can currently use |
In that case disregard what I've just said. I've only been developing new apps with Laravel but this would make it hard to work with some legacy apps that have strange column naming schemes (or rather lack of naming schemes) and so probably should be removed. |
Eloquent has always required snake_case column names, and Laravel 4 is no different. PSR doesn't even dictate property names, and actually states that they can be either snake_case or camelCase. Just use snake_case with Eloquent like you always have. It's really not that complicated I don't think. |
I don't mind juggling that sort of thing. The the point of this issue is that |
Just use the casing of your database fields. There is no magic going on. |
The field is last_name and ->orderBy("lastName", "asc") errors....
The text was updated successfully, but these errors were encountered: