What’s the best and quickest way to create a new record using Laravel Eloquent or update the record if it exists ?
Here is my snippet:
<?php
$user = User::where('organization_id', '=', $organization_id)
->where('age', '=', 22)->first();
if ($user == null) {
// Insert a new record into the database
} else {
// Update the existing record
}
Any help?