Skip to content

Commit 457bb39

Browse files
zigzagdevclaude
andcommitted
fix: look up image by world_heritage_site_id instead of image PK
WorldHeritageVm.id is the site ID, not the image record's PK. Querying by world_heritage_site_id with is_primary/sort_order ordering returns the primary image for the site, which is what the frontend passes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 19bfcda commit 457bb39

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/app/Packages/Features/Controller/HeritageImageController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ class HeritageImageController extends Controller
1313
{
1414
public function proxyImage(Request $request, int $id): Response|JsonResponse
1515
{
16-
$image = Image::find($id);
16+
$image = Image::where('world_heritage_site_id', $id)
17+
->orderByDesc('is_primary')
18+
->orderBy('sort_order')
19+
->first();
1720

1821
if ($image === null) {
1922
return response()->json(['error' => 'Image not found'], 404);

0 commit comments

Comments
 (0)