Skip to content

Eloquent should support composite keys #5355

@aebersold

Description

@aebersold

Eloquent assumes heavily that you are using surrogate keys on your tables (the id field in every table). However in real world usage, particularly older database systems not designed with web frameworks in mind, there are often tables with composite keys. That is, the primary key is over two or more columns. Often, you can't just add autoincremented id's. This is definitely a game stopper for a lot of use-cases, where you are forced to access existing RDBMS (e.g. building a frontend for an existing db). See also this reddit post about this issue.

The schema builder has already support for composite keys, however eloquent doesn't seem to support it yet.

I request the feature to use composite keys in your eloquent models and queries. The default configuration for surrogate keys is fine, just add the option.

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