How to use updateOrInsert() method in Laravel Query?
updateOrInsert() method is used to update an existing record in the database if matching the condition or create if no matching record exists.
Its return type is Boolean.
Syntax
DB::table(‘blogs’)->updateOrInsert([Conditions],[fields with value]);
BY Best Interview Question ON 02 Mar 2023
Example
DB::table(‘blogs’)->updateOrInsert(
['email' => '[email protected]', 'title' => 'Best Interview Questions'],
['content' => 'Test Content']
);