Created
September 12, 2017 09:38
-
-
Save mityukov/8474efca4c06ef25570cd4e97f8b5dac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActivityRepositoryEloquent extends BaseRepository implements ActivityRepository | |
{ | |
// ... | |
public function insertMany($records) | |
{ | |
$searchFields = [ | |
'subdomain', | |
'element_type', | |
'element_id', | |
'slug', | |
]; | |
foreach ($records as $record) { | |
$record['deleted'] = false; | |
$this->model->updateOrCreate( | |
array_only($record, $searchFields), | |
array_except($record, $searchFields) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current implementation of something like
updateOrCreateMany
. But it's very slow even with compound index, consisting of all$searchFields
.