Conversation
…mage_url-into-heritage-command chore: world_heritage-split-command-refactor
Fix/api detail layout
…est-fix test: add image contract tests for getHeritageById
…-command chore: remove runtime usage of image_url from commands and query services
chore: drop image_url column from world_heritage_sites
fix: fix image url key in split JSON and cleanup image_url references
Feat/clean up code
There was a problem hiding this comment.
Pull request overview
Migrates world-heritage image handling away from legacy world_heritage_sites.image_url / primary_image_url columns and toward the world_heritage_site_images table, updating query paths, importer/normalizer behavior, and related tests/seed data.
Changes:
- Drops legacy
image_url/primary_image_urlcolumns and removes seeder/test data that still referenced them. - Updates query/services and Algolia indexing to derive thumbnail/primary image from
world_heritage_site_images. - Adjusts detail-query tests to validate the
imagesarray contract.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/database/seeders/WorldHeritageSeeder.php | Removes legacy image_url seed field. |
| src/database/migrations/2026_03_29_155722_drop_primary_image_url_from_world_heritage_sites.php | Drops primary_image_url column. |
| src/database/migrations/2026_03_29_151147_drop_image_url_from_world_heritage_sites.php | Drops image_url column. |
| src/app/Packages/Features/QueryUseCases/QueryServiceInterface/WorldHeritageQueryServiceInterface.php | Removes getHeritagesByIds() from the query service interface. |
| src/app/Packages/Domains/WorldHeritageReadQueryService.php | Uses primary image relation; used by Algolia search result hydration. |
| src/app/Packages/Domains/WorldHeritageQueryService.php | Switches list payload thumbnail source to images table; removes getHeritagesByIds() implementation; adjusts image DTO mapping. |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php | Adds/updates tests for images array contract and empty behavior. |
| src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_countEachRegionTest.php | Removes legacy image_url from test record seed. |
| src/app/Models/WorldHeritage.php | Removes thumbnail relation/fillable related to legacy thumbnail setup. |
| src/app/Models/Image.php | Aligns Image model to world_heritage_site_images table usage and adds casting. |
| src/app/Models/Country.php | Removes an unused import. |
| src/app/Console/Commands/SplitWorldHeritageJson.php | Stops emitting legacy image fields; refactors URL extraction/deduplication. |
| src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php | Stops writing legacy image_url on site import. |
| src/app/Console/Commands/AlgoliaImportWorldHeritages.php | Loads primary image via relation for Algolia thumbnail_url. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function casts(): array | ||
| { | ||
| return [ | ||
| 'is_primary' => 'boolean', | ||
| ]; | ||
| } |
There was a problem hiding this comment.
For consistency with other models in this codebase (e.g. WorldHeritage), consider declaring this as protected function casts(): array (or using a $casts property). While increasing visibility works in PHP, keeping it consistent helps tooling and readability.
...Packages/Features/QueryUseCases/QueryServiceInterface/WorldHeritageQueryServiceInterface.php
Show resolved
Hide resolved
| @@ -33,13 +33,15 @@ public function findByIdsPreserveOrder(array $ids): Collection | |||
| 'world_heritage_sites.latitude', | |||
| 'world_heritage_sites.longitude', | |||
| 'world_heritage_sites.short_description', | |||
There was a problem hiding this comment.
findByIdsPreserveOrder() feeds models into buildWorldHeritagePayload(), which includes unesco_site_url. Because this select list omits world_heritage_sites.unesco_site_url, search results built from these models will always return unesco_site_url as null. Include world_heritage_sites.unesco_site_url in the selected columns (or stop emitting it from the payload for this path).
| 'world_heritage_sites.short_description', | |
| 'world_heritage_sites.short_description', | |
| 'world_heritage_sites.unesco_site_url', |
| public function getAllHeritages( | ||
| int $currentPage, | ||
| int $perPage, | ||
| string $order | ||
| ): PaginationDto | ||
| { | ||
| ): PaginationDto { | ||
| $items = WorldHeritage::query() |
There was a problem hiding this comment.
This method signature puts the opening brace on the same line as the return type, while the rest of the class uses the brace on the next line. Since the repo uses Laravel Pint, this will likely be reformatted anyway; consider keeping it consistent (PSR-12 style) to avoid noisy diffs.
src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php
Outdated
Show resolved
Hide resolved
| array $extra = | ||
| [] |
There was a problem hiding this comment.
The default value for $extra is split across lines (array $extra = then []). This is valid PHP but inconsistent with the surrounding formatting and will likely be rewritten by Pint; please format it as a single parameter line (array $extra = []) or use a standard multiline style.
| array $extra = | |
| [] | |
| array $extra = [] |
| public function up(): void | ||
| { | ||
| Schema::table('world_heritage_sites', function (Blueprint $table) { | ||
| $table->dropColumn('primary_image_url'); |
There was a problem hiding this comment.
Indentation inside the Schema::table callback is inconsistent here (the dropped column line is over-indented and the closing brace is misaligned). Please reformat to the standard indentation to keep migrations consistent and avoid Pint reformat churn.
| $table->dropColumn('primary_image_url'); | |
| $table->dropColumn('primary_image_url'); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Images are now stored exclusively in
world_heritage_site_imagestableinstead of
world_heritage_sites.image_url/primary_image_url.Changes
main_image_url + images_urls→world_heritage_site_images#295 Define image mapping rulesimage_urlin importerimage_urlimage_urlfrom test files and seedersimage_url / primary_image_urlcolumnsVerification
php artisan app:world-heritage-build --fresh --jp --pretty --clear --algolia --algolia-truncateworld_heritage_site_images