Skip to content

Instantly share code, notes, and snippets.

@Encang-Cutbray
Last active December 7, 2021 10:58
Show Gist options
  • Save Encang-Cutbray/f0ae2f0c53917ffd0668687d71384c16 to your computer and use it in GitHub Desktop.
Save Encang-Cutbray/f0ae2f0c53917ffd0668687d71384c16 to your computer and use it in GitHub Desktop.
Laravel 5, Check perform if updateOrCreate
$user = UserModel::updateOrCreate(['name' => 'Cinta] ,['email' => 'cinta@email.com']);
if (!$user->wasRecentlyCreated && $user->wasChanged()) {
// This run as update
}
if ($user->wasRecentlyCreated) {
// This run as create
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment