Add images to prehistoric

This commit is contained in:
2025-05-07 16:41:23 +02:00
parent 696ef51508
commit e5810d94c6
3 changed files with 56 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\Image;
use App\Entity\Prehistoric;
//use App\Entity\Bibliography;
use Doctrine\ORM\EntityManagerInterface;
@@ -24,6 +25,14 @@ class PrehistoricController extends AbstractController
$id = $record->getId();
$record->setLat($repo->coordinates($id)['lat']);
$record->setLng($repo->coordinates($id)['lng']);
$repoImg = $em->getRepository(Image::class);
$images = $repoImg->findBy(
['prehistoric' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$records[$key] = $record;
}
@@ -46,6 +55,14 @@ class PrehistoricController extends AbstractController
$prehistoric->setLat($coordinates['lat']);
$prehistoric->setLng($coordinates['lng']);
$repo = $em->getRepository(Image::class);
$images = $repo->findBy(
['prehistoric' => $prehistoric->getId()],
['sequence' => 'ASC']
);
$prehistoric->setImages($images);
return $this->json($prehistoric);
}