Created
February 23, 2022 20:55
-
-
Save inxilpro/c4650bf3ecf739b0a5fba1243e0f9b5a to your computer and use it in GitHub Desktop.
This file contains 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
File 1: | |
REMOVE: LegacyRecord::each(function($record) { | |
ADD: LegacyRecord::with('new_record')->each(function($record) { | |
$identity = ['legacy_id' => $record->id]; | |
$values = $this->transformLegacyRecord($record); | |
REMOVE: NewRecord::updateOrCreate($identity, $values); | |
ADD: $new_record = $record->new_record ?? NewRecord::make($identity); | |
ADD: $new_record->fill($this->transformLegacyRecord($record)); | |
ADD: $new_record->save(); | |
}); | |
File 2: | |
class LegacyRecord extends Model | |
{ | |
ADD: public function new_record() | |
ADD: { | |
ADD: return $this->hasOne(NewRecord::class, 'legacy_id'); | |
ADD: } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment