Probably it won't change any soon and it is working for relations (while not for the attributes) because of Model's getAttribute
method.
There anything not being an attribute, mutated prop, or already loaded relation (in that order) is supposed to be a call to the relation, and it's processed by camel_case
method and called.
Cheers, that sounds reasonable to me. Looks like it's not defined behaviour (i.e. "it should work like this") but it's as-good-as by the implementation and it's unlikely to change by the way everything else works, which possibly is defined behaviour.
Since I've upgraded to Laravel 5, all of my model->snake_case relationship calls are breaking. I've had to go back and change them all to camelCase. Has anyone noticed this behavior or can anyone point to documentation or anything that verifies this?
There are inconsistencies in laravel 4.2 as well. Specifically, accessing relations via snake_case circumvents eager loading. If you do a search for snake_case on the Laravel GitHub issue tracker you'll see that supporting both camel and snake case has been difficult and fraught with trade-offs.
There was a 4.2 request to remove the ability to use snake_case relationships because they misbehave. However, Taylor's response was to not fix it and the change was pushed to 5.0.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community