LaravelDaily/Test-Laravel-Eloquent-Basics

## Task 7. Update or New Record.

raimondsL opened this issue · 0 comments

// TASK: find a user by $name and update it with $email
// if not found, create a user with $name, $email and random password

$user = User::updateOrCreate(
    ['name' => $name],
    ['email' => $email, 'password' => bcrypt(Str::random(8))]
);

Laravel updateOrCreate doesn't have a 3rd argument - the password will be updated every time with email and pass the test