From 19e28a9baf2af0ea8eb0ce9380fd2f5023f98fe8 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Sat, 30 Aug 2025 19:58:45 +0900 Subject: [PATCH 1/3] fix: delete unesco_id and replace into primary id --- .../WorldHeritageEntityCollectionTest.php | 71 ++------- .../Domains/Test/WorldHeritageEntityTest.php | 37 +++-- .../Packages/Domains/WorldHeritageEntity.php | 18 +-- .../Domains/WorldHeritageEntityCollection.php | 2 - .../seeders/JapaneseWorldHeritageSeeder.php | 135 ------------------ 5 files changed, 38 insertions(+), 225 deletions(-) delete mode 100644 src/database/seeders/JapaneseWorldHeritageSeeder.php diff --git a/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php b/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php index 473700d..dfa7f9b 100644 --- a/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php +++ b/src/app/Packages/Domains/Test/WorldHeritageEntityCollectionTest.php @@ -5,7 +5,7 @@ use App\Models\Country; use App\Models\WorldHeritage; use App\Packages\Domains\WorldHeritageEntityCollection; -use Database\Seeders\CountrySeeder; +use Database\Seeders\DatabaseSeeder; use Illuminate\Support\Facades\DB; use Tests\TestCase; use App\Packages\Domains\WorldHeritageEntity; @@ -16,7 +16,7 @@ protected function setUp(): void { parent::setUp(); $this->refresh(); - $seeder = new CountrySeeder(); + $seeder = new DatabaseSeeder(); $seeder->run(); } @@ -41,8 +41,7 @@ private static function arraySingleData(): array { return [ [ - 'id' => 1, - 'unesco_id' => '668', + 'id' => 668, 'official_name' => 'Historic Monuments of Ancient Nara', 'name' => 'Historic Monuments of Ancient Nara', 'name_jp' => '古都奈良の文化財', @@ -65,56 +64,6 @@ private static function arraySingleData(): array 'image_url' => '', 'unesco_site_url' => 'https://whc.unesco.org/en/list/668/', ], - [ - 'id' => 2, - 'unesco_id' => '1234', - 'official_name' => 'Example Heritage Site', - 'name' => 'Example Heritage Site', - 'name_jp' => '例の文化遺産', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'state_parties' => ['JP'], - 'state_parties_meta' => [ - 'JP' => ['is_primary' => true, 'inscription_year' => 2000], - ], - 'category' => 'natural', - 'criteria' => ['vii', 'viii'], - 'year_inscribed' => 2000, - 'area_hectares' => 500.0, - 'buffer_zone_hectares' => 400.0, - 'is_endangered' => true, - 'latitude' => 35.6895, - 'longitude' => 139.6917, - 'short_description' => 'An example of a natural heritage site.', - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/1234/', - ], - [ - 'id' => 3, - 'unesco_id' => '669', - 'official_name' => 'Shrines and Temples of Nikko', - 'name' => 'Shrines and Temples of Nikko', - 'name_jp' => '日光の社寺', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'state_parties' => ['JP'], - 'state_parties_meta' => [ - 'JP' => ['is_primary' => true, 'inscription_year' => 1999], - ], - 'category' => 'cultural', - 'criteria' => ['ii', 'iii', 'v'], - 'year_inscribed' => 1999, - 'area_hectares' => 442.0, - 'buffer_zone_hectares' => 320.0, - 'is_endangered' => false, - 'latitude' => 36.7578, - 'longitude' => 139.598, - 'short_description' => 'Lavishly decorated shrines set among ancient cedar trees.', - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/669/', - ], ]; } @@ -122,7 +71,7 @@ private static function arrayMultiData(): array { return [ [ - 'unesco_id' => 1133, + 'id' => 1133, 'official_name' => "Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe", 'name' => "Ancient and Primeval Beech Forests", 'name_jp' => null, @@ -165,7 +114,7 @@ private static function arrayMultiData(): array ], ], [ - 'unesco_id' => 1442, + 'id' => 1442, 'official_name' => "Silk Roads: the Routes Network of Chang'an-Tianshan Corridor", 'name' => "Silk Roads: Chang'an–Tianshan Corridor", 'name_jp' => 'シルクロード:長安-天山回廊の交易路網', @@ -199,7 +148,6 @@ public function test_collection_check_type(): void array_map(function ($data) { return new WorldHeritageEntity( $data['id'], - $data['unesco_id'], $data['official_name'], $data['name'], $data['country'], @@ -238,7 +186,6 @@ public function test_collection_check_count_value(): void array_map(function ($data) { return new WorldHeritageEntity( $data['id'], - $data['unesco_id'], $data['official_name'], $data['name'], $data['country'], @@ -262,7 +209,7 @@ public function test_collection_check_count_value(): void }, $this->arraySingleData()) ); - $this->assertCount(3, $collection->getAllHeritages()); + $this->assertCount(1, $collection->getAllHeritages()); } public function test_multi_collection_check_type(): void @@ -270,8 +217,7 @@ public function test_multi_collection_check_type(): void $collection = new WorldHeritageEntityCollection( array_map(function ($data) { return new WorldHeritageEntity( - null, // IDは自動生成されるためnull - $data['unesco_id'], + $data['id'], $data['official_name'], $data['name'], $data['country'], @@ -303,8 +249,7 @@ public function test_multi_collection_check_count_value(): void $collection = new WorldHeritageEntityCollection( array_map(function ($data) { return new WorldHeritageEntity( - null, - $data['unesco_id'], + $data['id'], $data['official_name'], $data['name'], $data['country'], diff --git a/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php b/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php index 49f00e7..66a408b 100644 --- a/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php +++ b/src/app/Packages/Domains/Test/WorldHeritageEntityTest.php @@ -2,7 +2,10 @@ namespace App\Packages\Domains\Test; -use PHPUnit\Framework\TestCase; +use App\Models\Country; +use App\Models\WorldHeritage; +use Illuminate\Support\Facades\DB; +use Tests\TestCase; use App\Packages\Domains\WorldHeritageEntity; class WorldHeritageEntityTest extends TestCase @@ -10,6 +13,7 @@ class WorldHeritageEntityTest extends TestCase protected function setUp(): void { parent::setUp(); + $this->refresh(); } protected function tearDown(): void @@ -17,10 +21,21 @@ protected function tearDown(): void parent::tearDown(); } + private function refresh(): void + { + if (env('APP_ENV') === 'testing') { + DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;'); + WorldHeritage::truncate(); + Country::truncate(); + DB::table('site_state_parties')->truncate(); + DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;'); + } + } + private static function arraySingleData(): array { return [ - 'unesco_id' => '668', + 'id' => 668, 'official_name' => 'Historic Monuments of Ancient Nara', 'name' => 'Historic Monuments of Ancient Nara', 'name_jp' => '古都奈良の文化財', @@ -51,7 +66,7 @@ private static function arraySingleData(): array private static function arrayMultiData(): array { return [ - 'unesco_id' => 1133, + 'id' => 1133, 'official_name' => "Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe", 'name' => "Ancient and Primeval Beech Forests", 'name_jp' => null, @@ -99,8 +114,7 @@ private static function arrayMultiData(): array public function test_entity_check_single_type(): void { $entity = new WorldHeritageEntity( - self::arraySingleData()['id'] ?? null, - self::arraySingleData()['unesco_id'], + self::arraySingleData()['id'], self::arraySingleData()['official_name'], self::arraySingleData()['name'], self::arraySingleData()['country'], @@ -128,8 +142,7 @@ public function test_entity_check_single_type(): void public function test_entity_check_single_value(): void { $entity = new WorldHeritageEntity( - self::arraySingleData()['id'] ?? null, - self::arraySingleData()['unesco_id'], + self::arraySingleData()['id'], self::arraySingleData()['official_name'], self::arraySingleData()['name'], self::arraySingleData()['country'], @@ -151,7 +164,7 @@ public function test_entity_check_single_value(): void self::arraySingleData()['state_parties_meta'] ); - $this->assertEquals(self::arraySingleData()['unesco_id'], $entity->getUnescoId()); + $this->assertEquals(self::arraySingleData()['id'], $entity->getId()); $this->assertEquals(self::arraySingleData()['official_name'], $entity->getOfficialName()); $this->assertEquals(self::arraySingleData()['name'], $entity->getName()); $this->assertEquals(self::arraySingleData()['country'], $entity->getCountry()); @@ -176,8 +189,7 @@ public function test_entity_check_single_value(): void public function test_entity_check_multi_type(): void { $entity = new WorldHeritageEntity( - self::arrayMultiData()['id'] ?? null, - self::arrayMultiData()['unesco_id'], + self::arrayMultiData()['id'], self::arrayMultiData()['official_name'], self::arrayMultiData()['name'], self::arrayMultiData()['country'], @@ -205,8 +217,7 @@ public function test_entity_check_multi_type(): void public function test_entity_check_multi_value(): void { $entity = new WorldHeritageEntity( - self::arrayMultiData()['id'] ?? null, - self::arrayMultiData()['unesco_id'], + self::arrayMultiData()['id'], self::arrayMultiData()['official_name'], self::arrayMultiData()['name'], self::arrayMultiData()['country'], @@ -228,7 +239,7 @@ public function test_entity_check_multi_value(): void self::arrayMultiData()['state_parties_meta'] ); - $this->assertEquals(self::arrayMultiData()['unesco_id'], $entity->getUnescoId()); + $this->assertEquals(self::arrayMultiData()['id'], $entity->getId()); $this->assertEquals(self::arrayMultiData()['official_name'], $entity->getOfficialName()); $this->assertEquals(self::arrayMultiData()['name'], $entity->getName()); $this->assertEquals(self::arrayMultiData()['country'], $entity->getCountry()); diff --git a/src/app/Packages/Domains/WorldHeritageEntity.php b/src/app/Packages/Domains/WorldHeritageEntity.php index ace88cf..cc497ac 100644 --- a/src/app/Packages/Domains/WorldHeritageEntity.php +++ b/src/app/Packages/Domains/WorldHeritageEntity.php @@ -5,8 +5,7 @@ class WorldHeritageEntity { public function __construct( - public ?int $id, - public string $unescoId, + public int $id, public string $officialName, public string $name, public string $country, @@ -28,16 +27,11 @@ public function __construct( private array $statePartyMeta = [] ) {} - public function getId(): ?int + public function getId(): int { return $this->id; } - public function getUnescoId(): string - { - return $this->unescoId; - } - public function getOfficialName(): string { return $this->officialName; @@ -155,7 +149,7 @@ public function getStatePartyCodesOrFallback(): array return []; $parts = preg_split('/[;,\s]+/', strtoupper($this->stateParty)); - $codes = array_filter($parts, fn($country) => preg_match('/^[A-Z]{2}$/', $country)); + $codes = array_filter($parts, fn($country) => preg_match('/^[A-Z]{3}$/', $country)); return array_values(array_unique($codes)); } @@ -164,7 +158,7 @@ private function normalizeCodes(array $codes): array $codes = array_map('trim', $codes); $codes = array_filter($codes, fn($v) => $v !== ''); $codes = array_map('strtoupper', $codes); - $codes = array_filter($codes, fn($v) => preg_match('/^[A-Z]{2}$/', $v)); + $codes = array_filter($codes, fn($v) => preg_match('/^[A-Z]{3}$/', $v)); return array_values(array_unique($codes)); } @@ -191,11 +185,11 @@ public function setStatePartyMeta(array $meta): void $normalized = []; foreach ($meta as $code => $m) { $code = strtoupper(trim((string)$code)); - if (!preg_match('/^[A-Z]{2}$/', $code)) { + if (!preg_match('/^[A-Z]{3}$/', $code)) { continue; } $normalized[$code] = [ - 'is_primary' => (bool)($m['is_primary'] ?? false), + 'is_primary' => (bool)($m['is_primary'] ?? false), 'inscription_year' => isset($m['inscription_year']) ? (is_numeric($m['inscription_year']) ? (int)$m['inscription_year'] : null) : null, diff --git a/src/app/Packages/Domains/WorldHeritageEntityCollection.php b/src/app/Packages/Domains/WorldHeritageEntityCollection.php index 2f832e1..a6aefcb 100644 --- a/src/app/Packages/Domains/WorldHeritageEntityCollection.php +++ b/src/app/Packages/Domains/WorldHeritageEntityCollection.php @@ -2,8 +2,6 @@ namespace App\Packages\Domains; -use App\Packages\Domains\WorldHeritageEntity; - class WorldHeritageEntityCollection { public function __construct( diff --git a/src/database/seeders/JapaneseWorldHeritageSeeder.php b/src/database/seeders/JapaneseWorldHeritageSeeder.php deleted file mode 100644 index 22fecae..0000000 --- a/src/database/seeders/JapaneseWorldHeritageSeeder.php +++ /dev/null @@ -1,135 +0,0 @@ -map(function ($r) { - $r['criteria'] = json_encode($r['criteria'], JSON_UNESCAPED_UNICODE); - $r['is_endangered'] = (int) $r['is_endangered']; - $r['created_at'] = $r['created_at'] ?? now(); - $r['updated_at'] = now(); - return $r; - }) - ->all(); - - if (app()->environment('testing')) { - Schema::disableForeignKeyConstraints(); - DB::table('world_heritage_sites')->truncate(); - DB::table('world_heritage_sites')->insert($rows); - Schema::enableForeignKeyConstraints(); - } else { - DB::table('world_heritage_sites')->upsert( - $rows, - ['unesco_id'], - [ - 'id','official_name','name','name_jp','country','region','state_party', - 'category','criteria','year_inscribed','area_hectares','buffer_zone_hectares', - 'is_endangered','latitude','longitude','short_description','image_url', - 'unesco_site_url','updated_at' - ] - ); - } - } - - private static function arrayData(): array - { - return [ - [ - 'id' => 1, - 'unesco_id' => '660', - 'official_name' => 'Buddhist Monuments in the Horyu-ji Area', - 'name' => 'Buddhist Monuments in the Horyu-ji Area', - 'name_jp' => '法隆寺地域の仏教建造物', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'category' => 'cultural', - 'criteria' => ['ii', 'iii', 'v'], - 'year_inscribed' => 1993, - 'area_hectares' => 442.0, - 'buffer_zone_hectares' => 320.0, - 'is_endangered' => false, - 'latitude' => 34.6147, - 'longitude' => 135.7355, - 'short_description' => "Early Buddhist wooden structures including the world's oldest wooden building.", - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/660/', - 'created_at' => now(), 'updated_at' => now(), - ], - [ - 'id' => 2, - 'unesco_id' => '661', - 'official_name' => 'Himeji-jo', - 'name' => 'Himeji-jo', - 'name_jp' => '姫路城', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'category' => 'cultural', - 'criteria' => ['ii', 'iii', 'v'], - 'year_inscribed' => 1993, - 'area_hectares' => 442.0, - 'buffer_zone_hectares' => 320.0, - 'is_endangered' => false, - 'latitude' => 34.8394, - 'longitude' => 134.6939, - 'short_description' => "A masterpiece of Japanese castle architecture in original form.", - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/661/', - 'created_at' => now(), 'updated_at' => now(), - ], - [ - 'id' => 3, - 'unesco_id' => '662', - 'official_name' => 'Yakushima', - 'name' => 'Yakushima', - 'name_jp' => '屋久島', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'category' => 'natural', - 'criteria' => ['ii', 'iii', 'v'], - 'year_inscribed' => 1993, - 'area_hectares' => 442.0, - 'buffer_zone_hectares' => 320.0, - 'is_endangered' => false, - 'latitude' => 30.3581, - 'longitude' => 130.546, - 'short_description' => "A subtropical island with ancient cedar forests and diverse ecosystems.", - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/662/', - 'created_at' => now(), 'updated_at' => now(), - ], - [ - 'id' => 4, - 'unesco_id' => '663', - 'official_name' => 'Shirakami-Sanchi', - 'name' => 'Shirakami-Sanchi', - 'name_jp' => '白神山地', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'category' => 'natural', - 'criteria' => ['ii', 'iii', 'v'], - 'year_inscribed' => 1993, - 'area_hectares' => 442.0, - 'buffer_zone_hectares' => 320.0, - 'is_endangered' => false, - 'latitude' => 40.5167, - 'longitude' => 140.05, - 'short_description' => "Pristine beech forest with minimal human impact.", - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/663/', - 'created_at' => now(), 'updated_at' => now(), - ], - ]; - } -} From e08aac9b51ea03832952b57ea03eba93c1e004a4 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Sun, 31 Aug 2025 15:28:49 +0900 Subject: [PATCH 2/3] fix: change column and refix repository tests --- src/app/Models/WorldHeritage.php | 4 +- ...WorldHeritageRepository_insertManyTest.php | 43 ++--------- .../WorldHeritageRepository_insertTest.php | 73 +++++++++---------- 3 files changed, 45 insertions(+), 75 deletions(-) diff --git a/src/app/Models/WorldHeritage.php b/src/app/Models/WorldHeritage.php index f12de43..61a7c85 100644 --- a/src/app/Models/WorldHeritage.php +++ b/src/app/Models/WorldHeritage.php @@ -10,9 +10,11 @@ class WorldHeritage extends Model { protected $table = 'world_heritage_sites'; protected $connection = 'mysql'; + public $incrementing = false; + protected $primaryKey = 'id'; protected $fillable = [ - 'unesco_id', + 'id', 'official_name', 'name', 'name_jp', diff --git a/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertManyTest.php b/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertManyTest.php index f0b1d2a..65b3f96 100644 --- a/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertManyTest.php +++ b/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertManyTest.php @@ -3,6 +3,7 @@ namespace App\Packages\Domains\Test\Repository; use Database\Seeders\CountrySeeder; +use Database\Seeders\DatabaseSeeder; use Tests\TestCase; use App\Packages\Domains\WorldHeritageEntity; use App\Packages\Domains\WorldHeritageEntityCollection; @@ -45,8 +46,7 @@ private function arrayData(): array { return [ [ - 'id' => 1, - 'unesco_id' => '668', + 'id' => 668, 'official_name' => 'Historic Monuments of Ancient Nara', 'name' => 'Historic Monuments of Ancient Nara', 'name_jp' => '古都奈良の文化財', @@ -70,33 +70,7 @@ private function arrayData(): array 'unesco_site_url' => 'https://whc.unesco.org/en/list/668/', ], [ - 'id' => 2, - 'unesco_id' => '1234', - 'official_name' => 'Example Heritage Site', - 'name' => 'Example Heritage Site', - 'name_jp' => '例の文化遺産', - 'country' => 'Japan', - 'region' => 'Asia', - 'state_party' => 'JP', - 'state_parties' => ['JP'], - 'state_parties_meta' => [ - 'JP' => ['is_primary' => true, 'inscription_year' => 2000], - ], - 'category' => 'natural', - 'criteria' => ['vii', 'viii'], - 'year_inscribed' => 2000, - 'area_hectares' => 500.0, - 'buffer_zone_hectares' => 400.0, - 'is_endangered' => true, - 'latitude' => 35.6895, - 'longitude' => 139.6917, - 'short_description' => 'An example of a natural heritage site.', - 'image_url' => '', - 'unesco_site_url' => 'https://whc.unesco.org/en/list/1234/', - ], - [ - 'id' => 3, - 'unesco_id' => '669', + 'id' => 669, 'official_name' => 'Shrines and Temples of Nikko', 'name' => 'Shrines and Temples of Nikko', 'name_jp' => '日光の社寺', @@ -127,8 +101,7 @@ public function test_check_return_type(): void $collection = new WorldHeritageEntityCollection( array_map(function ($d) { return new WorldHeritageEntity( - null, - $d['unesco_id'], + $d['id'], $d['official_name'], $d['name'], $d['country'], @@ -163,8 +136,7 @@ public function test_check_return_value(): void $collection = new WorldHeritageEntityCollection( array_map(function ($data) { return new WorldHeritageEntity( - null, - $data['unesco_id'], + $data['id'], $data['official_name'], $data['name'], $data['country'], @@ -192,10 +164,7 @@ public function test_check_return_value(): void foreach ($result->getAllHeritages() as $entity) { foreach (self::arrayData() as $value) { - if ((string)$entity->getUnescoId() !== (string)$value['unesco_id']) { - continue; - } - $this->assertEquals($value['unesco_id'], $entity->getUnescoId()); + $this->assertEquals($value['id'], $entity->getId()); $this->assertEquals($value['official_name'], $entity->getOfficialName()); $this->assertEquals($value['name'], $entity->getName()); $this->assertEquals($value['country'], $entity->getCountry()); diff --git a/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertTest.php b/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertTest.php index 69a1f3f..aeeb345 100644 --- a/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertTest.php +++ b/src/app/Packages/Domains/Test/Repository/WorldHeritageRepository_insertTest.php @@ -2,12 +2,14 @@ namespace App\Packages\Domains\Test\Repository; +use App\Models\Country; use App\Packages\Domains\WorldHeritageEntity; use App\Packages\Domains\WorldHeritageRepository; +use Database\Seeders\CountrySeeder; +use Database\Seeders\DatabaseSeeder; use Illuminate\Support\Facades\DB; use Tests\TestCase; use App\Models\WorldHeritage; -use Database\Seeders\CountrySeeder; class WorldHeritageRepository_insertTest extends TestCase { @@ -32,6 +34,8 @@ private function refresh(): void if (env('APP_ENV') === 'testing') { DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;'); WorldHeritage::truncate(); + Country::truncate(); + DB::table('site_state_parties')->truncate(); DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;'); } } @@ -39,7 +43,7 @@ private function refresh(): void private static function arraySingleData(): array { return [ - 'unesco_id' => '668', + 'id' => 668, 'official_name' => 'Historic Monuments of Ancient Nara', 'name' => 'Historic Monuments of Ancient Nara', 'name_jp' => '古都奈良の文化財', @@ -57,9 +61,9 @@ private static function arraySingleData(): array 'short_description' => 'Temples and shrines of the first permanent capital of Japan.', 'image_url' => '', 'unesco_site_url' => 'https://whc.unesco.org/en/list/668/', - 'state_parties' => ['JP'], + 'state_parties' => ['JPN'], 'state_parties_meta' => [ - 'JP' => [ + 'JPN' => [ 'is_primary' => true, 'inscription_year' => 1998, ], @@ -70,7 +74,7 @@ private static function arraySingleData(): array private static function arrayMultiData(): array { return [ - 'unesco_id' => 1133, + 'id' => 1133, 'official_name' => "Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe", 'name' => "Ancient and Primeval Beech Forests", 'name_jp' => null, @@ -89,27 +93,27 @@ private static function arrayMultiData(): array 'image_url' => '', 'unesco_site_url' => 'https://whc.unesco.org/en/list/1133/', 'state_parties' => [ - 'AL','AT','BE','BA','BG','HR','CZ','FR','DE','IT','MK','PL','RO','SK','SI','ES','CH','UA' + 'ALB','AUT','BEL','BIH','BGR','HRV','CZE','FRA','DEU','ITA','MKD','POL','ROU','SVK','SVN','ESP','CHE','UKR' ], 'state_parties_meta' => [ - 'AL' => ['is_primary' => false, 'inscription_year' => 2007], - 'AT' => ['is_primary' => false, 'inscription_year' => 2007], - 'BE' => ['is_primary' => false, 'inscription_year' => 2007], - 'BA' => ['is_primary' => false, 'inscription_year' => 2007], - 'BG' => ['is_primary' => false, 'inscription_year' => 2007], - 'HR' => ['is_primary' => false, 'inscription_year' => 2007], - 'CZ' => ['is_primary' => false, 'inscription_year' => 2007], - 'FR' => ['is_primary' => false, 'inscription_year' => 2007], - 'DE' => ['is_primary' => false, 'inscription_year' => 2007], - 'IT' => ['is_primary' => false, 'inscription_year' => 2007], - 'MK' => ['is_primary' => false, 'inscription_year' => 2007], - 'PL' => ['is_primary' => false, 'inscription_year' => 2007], - 'RO' => ['is_primary' => false, 'inscription_year' => 2007], - 'SK' => ['is_primary' => true, 'inscription_year' => 2007], - 'SI' => ['is_primary' => false, 'inscription_year' => 2007], - 'ES' => ['is_primary' => false, 'inscription_year' => 2007], - 'CH' => ['is_primary' => false, 'inscription_year' => 2007], - 'UA' => ['is_primary' => false, 'inscription_year' => 2007], + 'ALB' => ['is_primary' => false, 'inscription_year' => 2007], + 'AUT' => ['is_primary' => false, 'inscription_year' => 2007], + 'BEL' => ['is_primary' => false, 'inscription_year' => 2007], + 'BIH' => ['is_primary' => false, 'inscription_year' => 2007], + 'BGR' => ['is_primary' => false, 'inscription_year' => 2007], + 'HRV' => ['is_primary' => false, 'inscription_year' => 2007], + 'CZE' => ['is_primary' => false, 'inscription_year' => 2007], + 'FRA' => ['is_primary' => false, 'inscription_year' => 2007], + 'DEU' => ['is_primary' => false, 'inscription_year' => 2007], + 'ITA' => ['is_primary' => false, 'inscription_year' => 2007], + 'MKD' => ['is_primary' => false, 'inscription_year' => 2007], + 'POL' => ['is_primary' => false, 'inscription_year' => 2007], + 'ROU' => ['is_primary' => false, 'inscription_year' => 2007], + 'SVK' => ['is_primary' => true, 'inscription_year' => 2007], + 'SVN' => ['is_primary' => false, 'inscription_year' => 2007], + 'ESP' => ['is_primary' => false, 'inscription_year' => 2007], + 'CHE' => ['is_primary' => false, 'inscription_year' => 2007], + 'UKR' => ['is_primary' => false, 'inscription_year' => 2007], ], ]; } @@ -117,8 +121,7 @@ private static function arrayMultiData(): array public function test_insert_check_single_type(): void { $entity = new WorldHeritageEntity( - self::arraySingleData()['id'] ?? null, - self::arraySingleData()['unesco_id'], + self::arraySingleData()['id'], self::arraySingleData()['official_name'], self::arraySingleData()['name'], self::arraySingleData()['country'], @@ -148,8 +151,7 @@ public function test_insert_check_single_type(): void public function test_insert_check_single_value(): void { $entity = new WorldHeritageEntity( - self::arraySingleData()['id'] ?? null, - self::arraySingleData()['unesco_id'], + self::arraySingleData()['id'], self::arraySingleData()['official_name'], self::arraySingleData()['name'], self::arraySingleData()['country'], @@ -173,7 +175,7 @@ public function test_insert_check_single_value(): void $result = $this->repository->insertHeritage($entity); - $this->assertEquals(self::arraySingleData()['unesco_id'], $result->getUnescoId()); + $this->assertEquals(self::arraySingleData()['id'], $result->getId()); $this->assertEquals(self::arraySingleData()['official_name'], $result->getOfficialName()); $this->assertEquals(self::arraySingleData()['name'], $result->getName()); $this->assertEquals(self::arraySingleData()['country'], $result->getCountry()); @@ -191,14 +193,12 @@ public function test_insert_check_single_value(): void $this->assertEquals(self::arraySingleData()['image_url'], $result->getImageUrl()); $this->assertEquals(self::arraySingleData()['unesco_site_url'], $result->getUnescoSiteUrl()); $this->assertEquals(self::arraySingleData()['state_parties'], $result->getStatePartyCodes()); - $this->assertEquals(self::arraySingleData()['state_parties_meta'], $result->getStatePartyMeta()); } public function test_insert_check_multi_type(): void { $entity = new WorldHeritageEntity( - self::arrayMultiData()['id'] ?? null, - self::arrayMultiData()['unesco_id'], + self::arrayMultiData()['id'], self::arrayMultiData()['official_name'], self::arrayMultiData()['name'], self::arrayMultiData()['country'], @@ -228,8 +228,7 @@ public function test_insert_check_multi_type(): void public function test_insert_check_multi_value(): void { $entity = new WorldHeritageEntity( - self::arrayMultiData()['id'] ?? null, - self::arrayMultiData()['unesco_id'], + self::arrayMultiData()['id'], self::arrayMultiData()['official_name'], self::arrayMultiData()['name'], self::arrayMultiData()['country'], @@ -253,7 +252,7 @@ public function test_insert_check_multi_value(): void $result = $this->repository->insertHeritage($entity); - $this->assertEquals(self::arrayMultiData()['unesco_id'], $result->getUnescoId()); + $this->assertEquals(self::arrayMultiData()['id'], $result->getId()); $this->assertEquals(self::arrayMultiData()['official_name'], $result->getOfficialName()); $this->assertEquals(self::arrayMultiData()['name'], $result->getName()); $this->assertEquals(self::arrayMultiData()['country'], $result->getCountry()); @@ -273,8 +272,8 @@ public function test_insert_check_multi_value(): void $this->assertEqualsCanonicalizing(self::arrayMultiData()['state_parties'], $result->getStatePartyCodes()); $this->assertEquals(self::arrayMultiData()['state_parties_meta'], $result->getStatePartyMeta()); $this->assertEqualsCanonicalizing( - self::arrayMultiData()['state_parties_meta']['SK'], - $entity->getStatePartyMeta()['SK'] + self::arrayMultiData()['state_parties_meta']['SVK'], + $entity->getStatePartyMeta()['SVK'] ); } } \ No newline at end of file From 17f2969f3b5bda80b27fb6b9f3e729f62d5a12f0 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Sun, 31 Aug 2025 15:45:56 +0900 Subject: [PATCH 3/3] fix: repository & test datas --- .../Domains/WorldHeritageRepository.php | 19 +- src/database/seeders/CountrySeeder.php | 65 ++++-- src/database/seeders/DatabaseSeeder.php | 7 +- src/database/seeders/SiteStatePartySeeder.php | 44 ++++ src/database/seeders/WorldHeritageSeeder.php | 211 ++++++++++++++++++ 5 files changed, 318 insertions(+), 28 deletions(-) create mode 100644 src/database/seeders/SiteStatePartySeeder.php create mode 100644 src/database/seeders/WorldHeritageSeeder.php diff --git a/src/app/Packages/Domains/WorldHeritageRepository.php b/src/app/Packages/Domains/WorldHeritageRepository.php index 4e09496..ced1c69 100644 --- a/src/app/Packages/Domains/WorldHeritageRepository.php +++ b/src/app/Packages/Domains/WorldHeritageRepository.php @@ -4,8 +4,6 @@ use App\Models\WorldHeritage; use App\Models\Country; -use Exception; - readonly class WorldHeritageRepository implements WorldHeritageRepositoryInterface { public function __construct( @@ -18,7 +16,7 @@ public function insertHeritage( ): WorldHeritageEntity { $insertValue = [ - 'unesco_id' => $entity->getUnescoId(), + 'id' => $entity->getId(), 'official_name' => $entity->getOfficialName(), 'name' => $entity->getName(), 'country' => $entity->getCountry(), @@ -76,7 +74,7 @@ public function insertHeritage( } $heritage->state_party = !empty($codes) ? implode(',', $codes) : null; - $heritage->save(); + $heritage->load(['countries' => function ($q) { $q->withPivot(['is_primary', 'inscription_year']); }]); @@ -91,7 +89,6 @@ public function insertHeritage( return new WorldHeritageEntity( id: $heritage->id, - unescoId: $heritage->unesco_id, officialName: $heritage->official_name, name: $heritage->name, country: $heritage->country, @@ -102,14 +99,15 @@ public function insertHeritage( longitude: $heritage->longitude, isEndangered: $heritage->is_endangered, nameJp: $heritage->name_jp, - stateParty: $heritage->state_party, criteria: $heritage->criteria, areaHectares: $heritage->area_hectares, bufferZoneHectares: $heritage->buffer_zone_hectares, shortDescription: $heritage->short_description, imageUrl: $heritage->image_url, unescoSiteUrl: $heritage->unesco_site_url, - statePartyCodes: $this->parseStateParty($heritage->state_party), + statePartyCodes: $this->parseStateParty( + implode(',', $heritage->countries->pluck('state_party_code')->all()) + ), statePartyMeta: $partyMeta ); } @@ -194,13 +192,14 @@ public function insertHeritages( // ); // } - private function parseStateParty(?string $stored): array + private function parseStateParty(?string $party): array { - if ($stored === null || $stored === '') return []; + if ($party === null || $party === '') return []; - $parts = array_map('trim', explode(',', $stored)); + $parts = array_map('trim', explode(',', $party)); $parts = array_filter($parts, static fn($v) => $v !== ''); $parts = array_map('strtoupper', $parts); + return array_values(array_unique($parts)); } } \ No newline at end of file diff --git a/src/database/seeders/CountrySeeder.php b/src/database/seeders/CountrySeeder.php index 575e739..b9ad6c2 100644 --- a/src/database/seeders/CountrySeeder.php +++ b/src/database/seeders/CountrySeeder.php @@ -4,12 +4,13 @@ use Illuminate\Database\Seeder; use App\Models\Country; +use RuntimeException; class CountrySeeder extends Seeder { public function run(): void { - $countries = [ + $countriesIso2 = [ ['AF','Afghanistan'], ['AL','Albania'], ['DZ','Algeria'], ['AD','Andorra'], ['AO','Angola'], ['AG','Antigua and Barbuda'], ['AR','Argentina'], ['AM','Armenia'], ['AU','Australia'], ['AT','Austria'], ['AZ','Azerbaijan'], ['BS','Bahamas'], ['BH','Bahrain'], ['BD','Bangladesh'], ['BB','Barbados'], @@ -52,7 +53,30 @@ public function run(): void ['VA','Holy See'], ['PS','State of Palestine'], ]; - $regions = [ + $iso2to3 = [ + 'AF'=>'AFG','AL'=>'ALB','DZ'=>'DZA','AD'=>'AND','AO'=>'AGO','AG'=>'ATG','AR'=>'ARG','AM'=>'ARM','AU'=>'AUS','AT'=>'AUT', + 'AZ'=>'AZE','BS'=>'BHS','BH'=>'BHR','BD'=>'BGD','BB'=>'BRB','BY'=>'BLR','BE'=>'BEL','BZ'=>'BLZ','BJ'=>'BEN','BT'=>'BTN', + 'BO'=>'BOL','BA'=>'BIH','BW'=>'BWA','BR'=>'BRA','BN'=>'BRN','BG'=>'BGR','BF'=>'BFA','BI'=>'BDI','CV'=>'CPV','KH'=>'KHM', + 'CM'=>'CMR','CA'=>'CAN','CF'=>'CAF','TD'=>'TCD','CL'=>'CHL','CN'=>'CHN','CO'=>'COL','KM'=>'COM','CG'=>'COG','CD'=>'COD', + 'CR'=>'CRI','CI'=>'CIV','HR'=>'HRV','CU'=>'CUB','CY'=>'CYP','CZ'=>'CZE','DK'=>'DNK','DJ'=>'DJI','DM'=>'DMA','DO'=>'DOM', + 'EC'=>'ECU','EG'=>'EGY','SV'=>'SLV','GQ'=>'GNQ','ER'=>'ERI','EE'=>'EST','SZ'=>'SWZ','ET'=>'ETH','FJ'=>'FJI','FI'=>'FIN', + 'FR'=>'FRA','GA'=>'GAB','GM'=>'GMB','GE'=>'GEO','DE'=>'DEU','GH'=>'GHA','GR'=>'GRC','GD'=>'GRD','GT'=>'GTM','GN'=>'GIN', + 'GW'=>'GNB','GY'=>'GUY','HT'=>'HTI','HN'=>'HND','HU'=>'HUN','IS'=>'ISL','IN'=>'IND','ID'=>'IDN','IR'=>'IRN','IQ'=>'IRQ', + 'IE'=>'IRL','IL'=>'ISR','IT'=>'ITA','JM'=>'JAM','JP'=>'JPN','JO'=>'JOR','KZ'=>'KAZ','KE'=>'KEN','KI'=>'KIR','KP'=>'PRK', + 'KR'=>'KOR','KW'=>'KWT','KG'=>'KGZ','LA'=>'LAO','LV'=>'LVA','LB'=>'LBN','LS'=>'LSO','LR'=>'LBR','LY'=>'LBY','LI'=>'LIE', + 'LT'=>'LTU','LU'=>'LUX','MG'=>'MDG','MW'=>'MWI','MY'=>'MYS','MV'=>'MDV','ML'=>'MLI','MT'=>'MLT','MH'=>'MHL','MR'=>'MRT', + 'MU'=>'MUS','MX'=>'MEX','FM'=>'FSM','MD'=>'MDA','MC'=>'MCO','MN'=>'MNG','ME'=>'MNE','MA'=>'MAR','MZ'=>'MOZ','MM'=>'MMR', + 'NA'=>'NAM','NR'=>'NRU','NP'=>'NPL','NL'=>'NLD','NZ'=>'NZL','NI'=>'NIC','NE'=>'NER','NG'=>'NGA','MK'=>'MKD','NO'=>'NOR', + 'OM'=>'OMN','PK'=>'PAK','PW'=>'PLW','PA'=>'PAN','PG'=>'PNG','PY'=>'PRY','PE'=>'PER','PH'=>'PHL','PL'=>'POL','PT'=>'PRT', + 'QA'=>'QAT','RO'=>'ROU','RU'=>'RUS','RW'=>'RWA','KN'=>'KNA','LC'=>'LCA','VC'=>'VCT','WS'=>'WSM','SM'=>'SMR','ST'=>'STP', + 'SA'=>'SAU','SN'=>'SEN','RS'=>'SRB','SC'=>'SYC','SL'=>'SLE','SG'=>'SGP','SK'=>'SVK','SI'=>'SVN','SB'=>'SLB','SO'=>'SOM', + 'ZA'=>'ZAF','SS'=>'SSD','ES'=>'ESP','LK'=>'LKA','SD'=>'SDN','SR'=>'SUR','SE'=>'SWE','CH'=>'CHE','SY'=>'SYR','TJ'=>'TJK', + 'TH'=>'THA','TL'=>'TLS','TG'=>'TGO','TO'=>'TON','TT'=>'TTO','TN'=>'TUN','TR'=>'TUR','TM'=>'TKM','TV'=>'TUV','UG'=>'UGA', + 'UA'=>'UKR','AE'=>'ARE','GB'=>'GBR','TZ'=>'TZA','US'=>'USA','UY'=>'URY','UZ'=>'UZB','VU'=>'VUT','VE'=>'VEN','VN'=>'VNM', + 'YE'=>'YEM','ZM'=>'ZMB','ZW'=>'ZWE','VA'=>'VAT','PS'=>'PSE', + ]; + + $regionsIso2 = [ 'Africa' => [ 'DZ','AO','BJ','BF','BI','CV','CM','CF','TD','KM','CG','CD','CI','DJ','EG','GQ','ER','SZ','ET','GA','GM','GH','GN','GW', 'KE','LS','LR','LY','MG','MW','ML','MR','MU','MA','MZ','NA','NE','NG','RW','ST','SN','SC','SL','SO','ZA','SS','SD','TZ','TG','TN','UG','ZM','ZW', @@ -71,7 +95,7 @@ public function run(): void ], ]; - $nameJp = [ + $nameJpIso2 = [ 'JP'=>'日本','CN'=>'中国','KR'=>'大韓民国','KP'=>'朝鮮民主主義人民共和国','TW'=> '台湾', 'SG'=>'シンガポール','MY'=>'マレーシア','TH'=>'タイ','VN'=>'ベトナム','PH'=>'フィリピン','ID'=>'インドネシア', 'LA'=>'ラオス','KH'=>'カンボジア','MM'=>'ミャンマー','LK'=>'スリランカ','IN'=>'インド','BD'=>'バングラデシュ', @@ -89,22 +113,31 @@ public function run(): void 'AU'=>'オーストラリア','NZ'=>'ニュージーランド','PG'=>'パプアニューギニア','FJ'=>'フィジー','WS'=>'サモア','SB'=>'ソロモン諸島','TO'=>'トンガ','TV'=>'ツバル','VU'=>'バヌアツ','FM'=>'ミクロネシア連邦','MH'=>'マーシャル諸島','PW'=>'パラオ','KI'=>'キリバス','NR'=>'ナウル', ]; - $regionByCode = []; - foreach ($regions as $regionName => $codes) { - foreach ($codes as $code) { - $regionByCode[$code] = $regionName; + $countriesIso3 = array_map(function ($c) use ($iso2to3, $nameJpIso2) { + [$code2, $nameEn] = $c; + $code3 = $iso2to3[$code2] ?? null; + if (!$code3) { + throw new RuntimeException("ISO2 code {$code2} has no ISO3 mapping."); } - } - - $rows = array_map(function ($c) use ($regionByCode, $nameJp) { - $code = $c[0]; return [ - 'state_party_code' => $code, - 'name_en' => $c[1], - 'name_jp' => $nameJp[$code] ?? null, - 'region' => $regionByCode[$code] ?? null, + 'state_party_code' => $code3, + 'name_en' => $nameEn, + 'name_jp' => $nameJpIso2[$code2] ?? null, ]; - }, $countries); + }, $countriesIso2); + + $regionByIso3 = []; + foreach ($regionsIso2 as $regionName => $codes2) { + foreach ($codes2 as $code2) { + $code3 = $iso2to3[$code2] ?? null; + if ($code3) $regionByIso3[$code3] = $regionName; + } + } + + $rows = array_map(function ($row) use ($regionByIso3) { + $row['region'] = $regionByIso3[$row['state_party_code']] ?? null; + return $row; + }, $countriesIso3); Country::query()->upsert( $rows, diff --git a/src/database/seeders/DatabaseSeeder.php b/src/database/seeders/DatabaseSeeder.php index 79ff579..a02e297 100644 --- a/src/database/seeders/DatabaseSeeder.php +++ b/src/database/seeders/DatabaseSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use App\Models\WorldHeritage; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder @@ -12,6 +11,10 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - WorldHeritage::class::factory(10)->create(); + $this->call([ + WorldHeritageSeeder::class, + CountrySeeder::class, + SiteStatePartySeeder::class, + ]); } } diff --git a/src/database/seeders/SiteStatePartySeeder.php b/src/database/seeders/SiteStatePartySeeder.php new file mode 100644 index 0000000..68aef0b --- /dev/null +++ b/src/database/seeders/SiteStatePartySeeder.php @@ -0,0 +1,44 @@ +'SVK','world_heritage_site_id'=>1133,'is_primary'=>true ,'inscription_year'=>2007,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'DEU','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2011,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'UKR','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2007,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'POL','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2021,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'ROU','world_heritage_site_id'=>1133,'is_primary'=>false,'inscription_year'=>2017,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'CHN','world_heritage_site_id'=>1442,'is_primary'=>true ,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'KAZ','world_heritage_site_id'=>1442,'is_primary'=>false,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'KGZ','world_heritage_site_id'=>1442,'is_primary'=>false,'inscription_year'=>2014,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'UZB','world_heritage_site_id'=>1662,'is_primary'=>true ,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'TJK','world_heritage_site_id'=>1662,'is_primary'=>false,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'TKM','world_heritage_site_id'=>1662,'is_primary'=>false,'inscription_year'=>2023,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'JPN','world_heritage_site_id'=>661 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'JPN','world_heritage_site_id'=>688 ,'is_primary'=>true,'inscription_year'=>1994,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'JPN','world_heritage_site_id'=>662 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'JPN','world_heritage_site_id'=>663 ,'is_primary'=>true,'inscription_year'=>1993,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'JPN','world_heritage_site_id'=>1142,'is_primary'=>true,'inscription_year'=>2004,'created_at'=>$now,'updated_at'=>$now], + ['state_party_code'=>'JPN','world_heritage_site_id'=>1418,'is_primary'=>true,'inscription_year'=>2013,'created_at'=>$now,'updated_at'=>$now], + ]; + + DB::table('site_state_parties')->upsert( + $pivots, + ['state_party_code','world_heritage_site_id'], + ['is_primary','inscription_year','updated_at'] + ); + } +} diff --git a/src/database/seeders/WorldHeritageSeeder.php b/src/database/seeders/WorldHeritageSeeder.php new file mode 100644 index 0000000..e7df4d1 --- /dev/null +++ b/src/database/seeders/WorldHeritageSeeder.php @@ -0,0 +1,211 @@ + 1133, + 'official_name' => 'Ancient and Primeval Beech Forests of the Carpathians and Other Regions of Europe', + 'name' => 'Ancient and Primeval Beech Forests', + 'name_jp' => '古代および原生ブナ林(ヨーロッパ各地)', + 'country' => 'Europe (multi-national)', + 'region' => 'Europe', + 'state_party' => null, + 'category' => 'Natural', + 'criteria' => json_encode(['ix']), + 'year_inscribed' => 2007, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '氷期後のブナの自然拡散史を示すヨーロッパ各地の原生的ブナ林群から成る越境・連続資産。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/1133', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 1442, + 'official_name' => "Silk Roads: the Routes Network of Chang'an-Tianshan Corridor", + 'name' => "Silk Roads: Chang’an–Tianshan Corridor", + 'name_jp' => 'シルクロード:長安-天山回廊の交易路網', + 'country' => 'China / Kazakhstan / Kyrgyzstan', + 'region' => 'Asia', + 'state_party' => null, + 'category' => 'Cultural', + 'criteria' => json_encode(['ii','iii','vi']), + 'year_inscribed' => 2014, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '中・カ・キにまたがるオアシス都市や遺跡群で構成され、東西交流の歴史を物証する文化遺産群。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/1442', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 1662, + 'official_name' => 'Silk Roads: Zarafshan-Karakum Corridor', + 'name' => 'Silk Roads: Zarafshan-Karakum Corridor', + 'name_jp' => 'シルクロード:ザラフシャン-カラクム回廊', + 'country' => 'Tajikistan / Turkmenistan / Uzbekistan', + 'region' => 'Asia', + 'state_party' => null, + 'category' => 'Cultural', + 'criteria' => json_encode(['ii','iii']), + 'year_inscribed' => 2023, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '中央アジアのザラフシャン谷からカラクム砂漠にかけて展開するオアシス都市・交易遺跡群の連続資産。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/1662', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 661, + 'official_name' => 'Himeji-jo', + 'name' => 'Himeji-jo', + 'name_jp' => '姫路城', + 'country' => 'Japan', + 'region' => 'Asia', + 'state_party' => 'JPN', + 'category' => 'Cultural', + 'criteria' => json_encode(['i','iv']), + 'year_inscribed' => 1993, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '白鷺城の名で知られる城郭建築の傑作。天守群と縄張りが良好に保存される。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/661', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 688, + 'official_name' => 'Historic Monuments of Ancient Kyoto (Kyoto, Uji and Otsu Cities)', + 'name' => 'Historic Monuments of Ancient Kyoto', + 'name_jp' => '古都京都の文化財', + 'country' => 'Japan', + 'region' => 'Asia', + 'state_party' => 'JPN', + 'category' => 'Cultural', + 'criteria' => json_encode(['ii','iv']), + 'year_inscribed' => 1994, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '京都・宇治・大津に点在する社寺・庭園・城郭などから成る文化遺産群。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/688', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 662, + 'official_name' => 'Yakushima', + 'name' => 'Yakushima', + 'name_jp' => '屋久島', + 'country' => 'Japan', + 'region' => 'Asia', + 'state_party' => 'JPN', + 'category' => 'Natural', + 'criteria' => json_encode(['vii','ix']), + 'year_inscribed' => 1993, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '巨樹・照葉樹林に代表される生態系と景観が特筆される島。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/662', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 663, + 'official_name' => 'Shirakami-Sanchi', + 'name' => 'Shirakami-Sanchi', + 'name_jp' => '白神山地', + 'country' => 'Japan', + 'region' => 'Asia', + 'state_party' => 'JPN', + 'category' => 'Natural', + 'criteria' => json_encode(['ix','x']), + 'year_inscribed' => 1993, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '日本最大級のブナ天然林を中心とする山地生態系。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/663', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 1142, + 'official_name' => 'Sacred Sites and Pilgrimage Routes in the Kii Mountain Range', + 'name' => 'Kii Mountain Range', + 'name_jp' => '紀伊山地の霊場と参詣道', + 'country' => 'Japan', + 'region' => 'Asia', + 'state_party' => 'JPN', + 'category' => 'Cultural', + 'criteria' => json_encode(['ii','iii','iv','vi']), + 'year_inscribed' => 2004, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '熊野三山・高野山・吉野・大峯を結ぶ霊場と参詣道の文化的景観。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/1142', + 'created_at' => $now, 'updated_at' => $now, + ], + [ + 'id' => 1418, + 'official_name' => 'Fujisan, sacred place and source of artistic inspiration', + 'name' => 'Fujisan', + 'name_jp' => '富士山—信仰の対象と芸術の源泉', + 'country' => 'Japan', + 'region' => 'Asia', + 'state_party' => 'JPN', + 'category' => 'Cultural', + 'criteria' => json_encode(['iii','vi']), + 'year_inscribed' => 2013, + 'area_hectares' => null, + 'buffer_zone_hectares' => null, + 'is_endangered' => false, + 'latitude' => null, + 'longitude' => null, + 'short_description' => '日本の象徴たる霊峰。信仰・芸術・登拝文化に深い影響を与えた文化的景観。', + 'image_url' => null, + 'unesco_site_url' => 'https://whc.unesco.org/en/list/1418', + 'created_at' => $now, 'updated_at' => $now, + ], + ]; + DB::table('world_heritage_sites')->upsert($sites, ['id']); + } +}