updateorcreate laravel example
Example 1: laravel updateOrCreate
$flight = App\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
Example 2: update or create laravel
$user = User::updateOrCreate(['name' => request()->name], [
'foo' => request()->foo
]);
Example 3: laravel create or update
$flight = App\Models\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
Example 4: create new record via model in laravel
$userData = array('username' => 'Me', 'email' => 'me@yahoo.com');
User::create($userData);