I know using:
User::firstOrCreate(array(\'name\' => $input[\'name\'], \'email\' => $input[\'email\'], \'password\' => $input[\'password\']));
Previous answer is obsolete. It's possible to achieve in one step since Laravel 5.3, firstOrCreate
now has second parameter values
, which is being used for new record, but not for search
$user = User::firstOrCreate([
'email' => 'dummy@domain.com'
], [
'firstName' => 'Taylor',
'lastName' => 'Otwell'
]);