Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added updateOrCreate function #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

casenjo
Copy link

@casenjo casenjo commented Dec 9, 2015

The Repository class is missing a very useful function to be able to create
a model if it doesn't exist, or update it if it does.

The updateOrCreate($attributes, $values) function was added to the
Repository contract and abstract class to account for this.

One of the great functions that Eloquent has is to be able to create
a model if it doesn't exist, or update it if it does.

Calling $model->updateOrCreate($attributes, $values) will search for a
model matching the values in $attributes and if found will update it
with the values in $values. If it wasn't found, then it will create a
model for it. In both situations the instance of that model will be
returned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant