最佳答案
I'm using Laravel's function firstOrNew()
to create a new user or find and update an existing one.
How can I know, after the object is created, if it existed before or if it's a new object?
The idea is something like this:
$user = \App\User::firstOrNew([
'email' => $userData->getEmail(),
'name' => $userData->getName(),
]);
if ($user->new) { // some way to check
// user was created now
} else {
//user already existed
}