Images for NotConserved

This commit is contained in:
Nicolò P 2025-04-28 12:36:42 +02:00
parent f573b4deca
commit 68854f875b
4 changed files with 48 additions and 1 deletions

View File

@ -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,

View File

@ -59,7 +59,7 @@ class Finding implements \JsonSerializable
private ?array $bibliography = null;
/**
* @var Bibliography[] $images
* @var Image[] $images
*/
private ?array $images = null;

View File

@ -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;

View File

@ -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,
];
}
}