https://dev.to/norbybaru #overview Overview https://laravel.com/docs/master/eloquent is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. A Model in this case will be a representation of a database row as well as entity relationship.
However in case the record was not found, new record will be created and persisted to the database using given data.
use App\Models\Flight; // Update flight where departure and destination with price and discounted // or create new record with departure, destination, price and discounted $flight = Flight::updateOrCreate(['departure' => 'Oakland', 'destination' => 'San Diego'], ['price' => 99, 'discounted' => 1]); Enter fullscreen mode