Add images in Finding index
This commit is contained in:
parent
f35be9c845
commit
386653b6bf
@ -16,6 +16,7 @@ class FindingController extends AbstractController
|
|||||||
public function index(EntityManagerInterface $em): JsonResponse
|
public function index(EntityManagerInterface $em): JsonResponse
|
||||||
{
|
{
|
||||||
$repo = $em->getRepository(Finding::class);
|
$repo = $em->getRepository(Finding::class);
|
||||||
|
$imgRepo = $em->getRepository(Image::class);
|
||||||
|
|
||||||
$findings = $repo->findBy([], ['label' => 'ASC']);
|
$findings = $repo->findBy([], ['label' => 'ASC']);
|
||||||
|
|
||||||
@ -23,6 +24,12 @@ class FindingController extends AbstractController
|
|||||||
$coords = $repo->coordinates($finding->getId());
|
$coords = $repo->coordinates($finding->getId());
|
||||||
$finding->setLat($coords['lat']);
|
$finding->setLat($coords['lat']);
|
||||||
$finding->setLng($coords['lng']);
|
$finding->setLng($coords['lng']);
|
||||||
|
// TODO N + 1!!
|
||||||
|
$images = $imgRepo->findBy(
|
||||||
|
['finding' => $finding->getId()],
|
||||||
|
['sequence' => 'ASC']
|
||||||
|
);
|
||||||
|
$finding->setImages($images);
|
||||||
$findings[$key] = $finding;
|
$findings[$key] = $finding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ class ReuseController extends AbstractController
|
|||||||
public function index(EntityManagerInterface $em): JsonResponse
|
public function index(EntityManagerInterface $em): JsonResponse
|
||||||
{
|
{
|
||||||
$repo = $em->getRepository(Reuse::class);
|
$repo = $em->getRepository(Reuse::class);
|
||||||
//$repoBib = $em->getRepository(Bibliography::class);
|
|
||||||
$repoImg = $em->getRepository(Image::class);
|
$repoImg = $em->getRepository(Image::class);
|
||||||
|
|
||||||
$records = $repo->findBy([], ['label' => 'ASC']);
|
$records = $repo->findBy([], ['label' => 'ASC']);
|
||||||
@ -26,8 +25,6 @@ class ReuseController extends AbstractController
|
|||||||
$id = $record->getId();
|
$id = $record->getId();
|
||||||
$record->setLat($repo->coordinates($id)['lat']);
|
$record->setLat($repo->coordinates($id)['lat']);
|
||||||
$record->setLng($repo->coordinates($id)['lng']);
|
$record->setLng($repo->coordinates($id)['lng']);
|
||||||
//$biblio = $repoBib->findAllByNotConserved($id);
|
|
||||||
//$record->setBibliographies($biblio);
|
|
||||||
$images = $repoImg->findBy(
|
$images = $repoImg->findBy(
|
||||||
['reuse' => $record->getId()],
|
['reuse' => $record->getId()],
|
||||||
['sequence' => 'ASC']
|
['sequence' => 'ASC']
|
||||||
|
Loading…
Reference in New Issue
Block a user