Laravel 5.1 Create or Update on Duplicate

As per the Definition of the Eloquent Model Method “updateOrCreate()”

function updateOrCreate(array $attributes, array $values = []){}

it takes two argument …

  1. one is the attributes using which you want to check in database if the record is present
  2. second is the new attribute values that you want to create or update

AppInfo::updateOrCreate(['app_id' => $postData['appId']],
                        ['contact_email' => $postData['contactEmail']]);

Leave a Comment

tech