In my VUE app the user object has a property called nice_items. Where does that conversion from camelCase to snake_case happen? I could not find anything in the Interia docs.
@vincent15000 Where did you get that from? Did not find it at https://laravel.com/docs/9.x/eloquent-relationships#one-to-many ? When I have a relation ship method called getThisWonderfullNameAttribute() then I usually access the relation without brackets $user->getThisWonderfullNameAttribute; will return the collection (and not the builder class).
When you load a relationship on a model $user->load('niceItems'), Laravel will automatically rename it in snake case. It's the Laravel naming convention.
@vincent15000 hm, I am not sure if this is true, if dump dd($user->nice_items) after the load call, I receive null, but dd($user->niceItems) returns the collection
@vincent15000 yes, I just finish readining the page, but I don't see how it relates to my question, as I am not using Accessor, Mutators or Caster.
However, you are right, loaded relationships are transformed to json object from camel case to snake case. I found the paragraph in the docs here:
When an Eloquent model is converted to JSON, its loaded relationships will automatically be included as attributes on the JSON object. Also, though Eloquent relationship methods are defined using "camel case" method names, a relationship's JSON attribute will be "snake case".