$tourist = Tourist::updateOrCreate([...]);
if(!$tourist->wasRecentlyCreated && $tourist->wasChanged()){
// updateOrCreate performed an update
}
if(!$tourist->wasRecentlyCreated && !$tourist->wasChanged()){
// updateOrCreate performed nothing, row did not change
}
if($tourist->wasRecentlyCreated){
// updateOrCreate performed create
}
Last active
August 12, 2021 22:07
-
-
Save mknparreira/ef28ab7214073e81bb1dacc7613fdc96 to your computer and use it in GitHub Desktop.
Laravel | check if updateOrCreate performed update
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: https://stackoverflow.com/questions/45702409/laravel-check-if-updateorcreate-performed-update