Skip to content

Automatic Conversion Between camelCase and snake_case #176

Closed
@mikebronner

Description

@mikebronner

I am trying to put a proper convention into place for my current (new) project, and am struggling with worrying about casing for database naming conventions vs code naming conventions.

I believe Eloquent will automatically convert between camelCase for class attributes and snake_case for database field names. (Issue #50 seemed to touch on this.) I don't believe Laravel-MongoDB is doing this at the moment, as all my collections are being created using camelCase, with the exception of the system fields (created_at, etc.).

Then I started wondering if I should even concern myself with this, as the code in Laravel takes precedence over what's in the database, as that is abstracted so much already anyway (why should I concern myself, when I only see the class attributes?).

On the other hand, is there a way to do this? Similar to how we can specify the collection (table) name in the class, can we specify field names?

What are the current thoughts on this subject?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions