insertOrCreate laravel code example
Example 1: update or create laravel
$user = User::updateOrCreate(['name' => request()->name], [
'foo' => request()->foo
]);
Example 2: create new record via model in laravel
$userData = array('username' => 'Me', 'email' => '[email protected]');
User::create($userData);