@@ -134,18 +134,20 @@ class TerritoryReferenceSeeder extends Seeder
|
||||
}
|
||||
|
||||
$type = $record['location_type'];
|
||||
$expectedParent = [
|
||||
$parentTypes = [
|
||||
'country' => null,
|
||||
'province' => 'country',
|
||||
'district' => 'province',
|
||||
'admin_post' => 'district',
|
||||
'locality' => 'admin_post',
|
||||
][$type] ?? false;
|
||||
];
|
||||
|
||||
if ($expectedParent === false || isset($seen[$record['id']])) {
|
||||
if (! array_key_exists($type, $parentTypes) || isset($seen[$record['id']])) {
|
||||
throw new RuntimeException('Territory reference has an invalid type or duplicate ID.');
|
||||
}
|
||||
|
||||
$expectedParent = $parentTypes[$type];
|
||||
|
||||
if ($expectedParent === null) {
|
||||
if ($record['parent_id'] !== null) {
|
||||
throw new RuntimeException('Country reference cannot have a parent.');
|
||||
|
||||
Reference in New Issue
Block a user