Skip to content

Commit

Permalink
Blueprint acessories observer
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnakamura committed Jun 12, 2022
1 parent 5c4c387 commit 72c26e2
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/Observers/RealEstateDevelopment/BlueprintObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@ public function created($blueprint)
return;
}

$blueprint->loadMissing('real_estate_development');
$blueprint->refresh();
$blueprint->loadMissing(
'real_estate_development',
'real_estate_developments_characteristics'
);
if ($blueprint->real_estate_developments_characteristics) {
foreach ($blueprint->real_estate_developments_characteristics as $realEstateDevelopmentAccessory) {
$realEstateDevelopmentAccessory->loadMissing(
'accessory'
);
if ($realEstateDevelopmentAccessory->accessory) {
$realEstateDevelopmentAccessory->accessory->loadMissing('accessory_categorization');
}
}
}

$data = $blueprint->toArray();
$data['sync_to'] = 'sys';
Expand All @@ -36,7 +50,21 @@ public function updated($blueprint)
return;
}

$blueprint->loadMissing('real_estate_development');
$blueprint->refresh();
$blueprint->loadMissing(
'real_estate_development',
'real_estate_developments_characteristics'
);
if ($blueprint->real_estate_developments_characteristics) {
foreach ($blueprint->real_estate_developments_characteristics as $realEstateDevelopmentAccessory) {
$realEstateDevelopmentAccessory->loadMissing(
'accessory'
);
if ($realEstateDevelopmentAccessory->accessory) {
$realEstateDevelopmentAccessory->accessory->loadMissing('accessory_categorization');
}
}
}

$data = $blueprint->toArray();
$data['sync_to'] = 'sys';
Expand Down

0 comments on commit 72c26e2

Please sign in to comment.