diff --git a/src/Controller/NotConservedController.php b/src/Controller/NotConservedController.php index c1bc8b6..592531f 100644 --- a/src/Controller/NotConservedController.php +++ b/src/Controller/NotConservedController.php @@ -4,6 +4,7 @@ namespace App\Controller; use App\Entity\NotConserved; use App\Entity\Bibliography; +use App\Entity\Image; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; @@ -49,6 +50,13 @@ class NotConservedController extends AbstractController $notConserved->setLat($coordinates['lat']); $notConserved->setLng($coordinates['lng']); + $repo = $em->getRepository(Image::class); + $images = $repo->findBy( + ['notConserved' => $notConserved->getId()], + ['sequence' => 'ASC'] + ); + + $notConserved->setImages($images); return $this->json( $notConserved, diff --git a/src/Entity/Finding.php b/src/Entity/Finding.php index 1cb2674..b4b61b0 100644 --- a/src/Entity/Finding.php +++ b/src/Entity/Finding.php @@ -59,7 +59,7 @@ class Finding implements \JsonSerializable private ?array $bibliography = null; /** - * @var Bibliography[] $images + * @var Image[] $images */ private ?array $images = null; diff --git a/src/Entity/Image.php b/src/Entity/Image.php index d144942..38a42f0 100644 --- a/src/Entity/Image.php +++ b/src/Entity/Image.php @@ -31,6 +31,9 @@ class Image implements \JsonSerializable #[ORM\Column(name: 'rinvenimento', type: Types::BIGINT, nullable: true)] private ?string $finding = null; + #[ORM\Column(name: 'non_conserv', type: Types::BIGINT, nullable: true)] + private ?string $notConserved = null; + #[ORM\Column(name: 'ordine', type: Types::SMALLINT)] private ?int $sequence = null; @@ -109,6 +112,18 @@ class Image implements \JsonSerializable return $this; } + public function getNotConserved(): ?string + { + return $this->notConserved; + } + + public function setNotConserved(?string $notConserved): static + { + $this->notConserved = $notConserved; + + return $this; + } + public function getSequence(): ?int { return $this->sequence; diff --git a/src/Entity/NotConserved.php b/src/Entity/NotConserved.php index 952ca70..5ea0663 100644 --- a/src/Entity/NotConserved.php +++ b/src/Entity/NotConserved.php @@ -40,6 +40,11 @@ class NotConserved implements \JsonSerializable #[ORM\Column(name: 'autore_scheda', length: 100, nullable: true)] private ?string $author = null; + /** + * @var Image[] $images + */ + private ?array $images = null; + public function getId(): ?int { return $this->id; @@ -148,6 +153,24 @@ class NotConserved implements \JsonSerializable return $this; } + /** + * @return Image[] + */ + public function getImages(): array + { + return $this->images; + } + + /** + * @param Image[] $images + */ + public function setImages(array $images): static + { + $this->images = $images; + + return $this; + } + public function jsonSerialize(): array { return [ @@ -159,6 +182,7 @@ class NotConserved implements \JsonSerializable 'shortDescription' => $this->shortDescription, 'author' => $this->author, 'bibliography' => $this->bibliographies, + 'images' => $this->images, ]; } }