'\d+'], normalizationContext: ['groups' => ['building_case:read', 'building:summary']], ), new Get( uriTemplate: '/building_cases/{id}/weights-report', requirements: ['id' => '\d+'], openapi: new OpenApiOperation( summary: 'Render case weights report', description: 'Returns a PDF report of bovines stored in the selected case.', ), output: false, provider: BuildingCaseWeightsReportProvider::class, ), ], security: "is_granted('ROLE_USER')", )] class BuildingCase { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['building:read', 'building_case:read'])] private ?int $id = null; #[ORM\Column] #[Groups(['building:read', 'building_case:read', 'bovine:read'])] #[SerializedName('caseNumber')] private ?int $case_number = null; #[ORM\Column(length: 255)] #[Groups(['building:read', 'building_case:read'])] private ?string $code = null; #[ORM\Column] #[Groups(['building:read', 'building_case:read'])] private ?int $capacity = null; /** * @var Collection */ #[ORM\OneToMany(targetEntity: BuildingCasePosition::class, mappedBy: 'buildingCase')] private Collection $id_case_position; #[ORM\ManyToOne(inversedBy: 'buildingCases')] #[Groups(['building_case:read', 'bovine:read'])] #[SerializedName('building')] private ?Building $id_building = null; /** * @var Collection */ #[ORM\OneToMany(targetEntity: Bovine::class, mappedBy: 'buildingCase')] #[Groups(['building_case:read'])] private Collection $bovines; public function __construct() { $this->id_case_position = new ArrayCollection(); $this->bovines = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setId(int $id): static { $this->id = $id; return $this; } public function getCaseNumber(): ?int { return $this->case_number; } public function setCaseNumber(int $case_number): static { $this->case_number = $case_number; return $this; } public function getCode(): ?string { return $this->code; } public function setCode(string $code): static { $this->code = $code; return $this; } public function getCapacity(): ?int { return $this->capacity; } public function setCapacity(int $capacity): static { $this->capacity = $capacity; return $this; } /** * @return Collection */ public function getIdCasePosition(): Collection { return $this->id_case_position; } public function addIdCasePosition(BuildingCasePosition $idCasePosition): static { if (!$this->id_case_position->contains($idCasePosition)) { $this->id_case_position->add($idCasePosition); $idCasePosition->setBuildingCase($this); } return $this; } public function removeIdCasePosition(BuildingCasePosition $idCasePosition): static { if ($this->id_case_position->removeElement($idCasePosition)) { // set the owning side to null (unless already changed) if ($idCasePosition->getBuildingCase() === $this) { $idCasePosition->setBuildingCase(null); } } return $this; } public function getIdBuilding(): ?Building { return $this->id_building; } public function setIdBuilding(?Building $id_building): static { $this->id_building = $id_building; return $this; } /** * @return array{label: string, couleur: string} */ #[Groups(['building:read', 'building_case:read'])] public function getStatut(): array { if ($this->bovines->count() > 0) { return ['label' => 'Occupé', 'couleur' => '#3A506B']; } return ['label' => 'Libre', 'couleur' => '#A3B18A']; } /** * @return Collection */ public function getBovines(): Collection { return $this->bovines; } public function addBovine(Bovine $bovine): static { if (!$this->bovines->contains($bovine)) { $this->bovines->add($bovine); $bovine->setBuildingCase($this); } return $this; } public function removeBovine(Bovine $bovine): static { if ($this->bovines->removeElement($bovine)) { if ($bovine->getBuildingCase() === $this) { $bovine->setBuildingCase(null); } } return $this; } }