141 lines
3.1 KiB
PHP
141 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
use Symfony\Component\Serializer\Attribute\SerializedName;
|
|
|
|
#[ORM\Entity]
|
|
class BuildingLayout
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
#[Groups(['building:read'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Groups(['building:read'])]
|
|
private ?string $name = null;
|
|
|
|
#[ORM\Column]
|
|
#[Groups(['building:read'])]
|
|
private ?int $columns = null;
|
|
|
|
#[ORM\Column]
|
|
#[Groups(['building:read'])]
|
|
private ?int $rows = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'buildingLayout')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?Building $id_building = null;
|
|
|
|
/**
|
|
* @var Collection<int, BuildingCasePosition>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: BuildingCasePosition::class, mappedBy: 'buildingLayout')]
|
|
#[Groups(['building:read'])]
|
|
#[SerializedName('casePositions')]
|
|
private Collection $id_case_position;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->id_case_position = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setId(int $id): static
|
|
{
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getColumns(): ?int
|
|
{
|
|
return $this->columns;
|
|
}
|
|
|
|
public function setColumns(int $columns): static
|
|
{
|
|
$this->columns = $columns;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRows(): ?int
|
|
{
|
|
return $this->rows;
|
|
}
|
|
|
|
public function setRows(int $rows): static
|
|
{
|
|
$this->rows = $rows;
|
|
|
|
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 Collection<int, BuildingCasePosition>
|
|
*/
|
|
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->setBuildingLayout($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->getBuildingLayout() === $this) {
|
|
$idCasePosition->setBuildingLayout(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|