Last active
December 7, 2021 10:58
-
-
Save Encang-Cutbray/f0ae2f0c53917ffd0668687d71384c16 to your computer and use it in GitHub Desktop.
Laravel 5, Check perform if updateOrCreate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$user = UserModel::updateOrCreate(['name' => 'Cinta] ,['email' => '[email protected]']); | |
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