Skip to content

Dev: Model needs new method - findOrCreate #5163

Open
@lonnieezell

Description

@lonnieezell

The Model should provide a new convenience method, findOrCreate that can be given a set of criteria to locate within the db table, or create a new record using that data and an additional set of data that was provided.

Must work with all currently supported databases.

Undecided which version would work fit the project best, so am open to discussion on this one:

$userModel->where('email', 'johnsmith@example.com')->findOrCreate(['key' => 'value', ...]);

// or

$userModel->findOrCreate(['existing_key' => 'value'], ['new_key' => 'value']);

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    devhacktoberfestIssues ready for someone to tackle during Hacktoberfestmissing featureReported issue which is not a bug but needs to be implemented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions