src/Entity/Tower.php line 291
<?phpnamespace App\Entity;use App\Repository\TowerRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;use Symfony\Component\Uid\Uuid;use Symfony\Component\Validator\Constraints as Assert;use function Symfony\Component\String\u;#[ORM\Entity(repositoryClass: TowerRepository::class)]class Tower implements \JsonSerializable{#[ORM\Id]#[ORM\Column(type: 'uuid', unique: true)]#[ORM\GeneratedValue(strategy: 'CUSTOM')]#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]private $id;#[ORM\Column(length: 255)]private ?string $type = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $description = null;#[ORM\Column(length: 255, nullable: true)]private ?string $address = null;#[ORM\Column]private ?\DateTimeImmutable $createdAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTime $updatedAt = null;#[ORM\ManyToOne(inversedBy: 'towers')]private ?City $city = null;#[ORM\Column]#[Assert\GreaterThanOrEqual(value: 0,message: "A altura não pode ser negativa.")]private ?int $height = null;#[ORM\OneToMany(mappedBy: 'tower', targetEntity: Spot::class)]private Collection $spots;#[ORM\OneToMany(mappedBy: 'tower', targetEntity: Rent::class)]private Collection $rents;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(length: 255, nullable: true)]#[Assert\GreaterThanOrEqual(value: 0,message: "O preço não pode ser negativo.")]private ?string $price = null;#[ORM\OneToMany(mappedBy: 'tower', targetEntity: Photo::class, cascade: ['persist', 'remove'])]private Collection $photos;#[ORM\OneToMany(mappedBy: 'tower', targetEntity: Document::class, cascade: ['persist', 'remove'])]private Collection $documents;public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getPrice(): ?string{return $this->price ?? 0;}public function setPrice(?string $price): self{$this->price = $price;return $this;}/*** @return Collection<int, Photo>*/public function getPhotos(): Collection{return $this->photos;}public function addPhoto(Photo $photo): self{if (!$this->photos->contains($photo)) {$this->photos->add($photo);$photo->setTower($this);}return $this;}public function removePhoto(Photo $photo): self{if ($this->photos->removeElement($photo)) {// set the owning side to null (unless already changed)if ($photo->getTower() === $this) {$photo->setTower(null);}}return $this;}public function __construct(){$this->createdAt = new \DateTimeImmutable();$this->updatedAt = new \DateTime();$this->spots = new ArrayCollection();$this->rents = new ArrayCollection();$this->photos = new ArrayCollection();$this->documents = new ArrayCollection();}public function getId(): ?Uuid{return $this->id;}public function getType(): ?string{return $this->type;}public function setType(string $type): self{$this->type = $type;return $this;}public function getDescription(): ?string{return $this->description ?? "";}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getAddress(): ?string{return $this->address ?? "";}public function setAddress(?string $address): self{$this->address = $address;return $this;}public function getCreatedAt(): ?\DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(\DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getUpdatedAt(): ?\DateTimeInterface{return $this->updatedAt;}public function setUpdatedAt(\DateTimeInterface $updatedAt): self{$this->updatedAt = $updatedAt;return $this;}public function getCity(): ?City{return $this->city;}public function setCity(?City $city): self{$this->city = $city;return $this;}public function getHeight(): ?int{return $this->height;}public function setHeight(int $height): self{$this->height = $height;return $this;}/*** @return Collection<int, Spot>*/public function getSpots(): Collection{return $this->spots;}public function addSpot(Spot $spot): self{if (!$this->spots->contains($spot)) {$this->spots->add($spot);$spot->setTower($this);}return $this;}public function removeSpot(Spot $spot): self{if ($this->spots->removeElement($spot)) {// set the owning side to null (unless already changed)if ($spot->getTower() === $this) {$spot->setTower(null);}}return $this;}/*** @return Collection<int, Rent>*/public function getRents(): Collection{return $this->rents;}public function addRent(Rent $rent): self{if (!$this->rents->contains($rent)) {$this->rents->add($rent);$rent->setTower($this);}return $this;}public function removeRent(Rent $rent): self{if ($this->rents->removeElement($rent)) {// set the owning side to null (unless already changed)if ($rent->getTower() === $this) {$rent->setTower(null);}}return $this;}public function __toString(){return $this->getType() . ' - ' . $this->getCity()->getName() .', '. $this->getCity()->getState() . ' - ' . $this->getAddress() . ' - ' . $this->getHeight() . 'm';}public function jsonSerialize(){return ['id' => $this->getId(),'type' => $this->getType(),'type' => $this->getType(),'type_folder' => u($this->getType())->snake(),'description' => $this->getDescription(),'address' => $this->getAddress(),'city' => $this->getCity()->getName(),'state' => $this->getCity()->getState(),'height' => $this->getHeight(),'spots' => $this->getSpots(),'photos' => $this->getPhotos(),];}/*** @return Collection<int, Document>*/public function getDocuments(): Collection{return $this->documents;}public function addDocument(Document $document): self{if (!$this->documents->contains($document)) {$this->documents->add($document);$document->setTower($this);}return $this;}public function removeDocument(Document $document): self{if ($this->documents->removeElement($document)) {// set the owning side to null (unless already changed)if ($document->getTower() === $this) {$document->setTower(null);}}return $this;}}class TowerType{const ESTAIADA = 'Estaiada';const AUTOPORTANTE_LINEAR = 'Autoportante Linear';const AUTOPORTANTE_MISTA = 'Autoportante Mista';const AUTOPORTANTE_TRIANGULAR = 'Autoportante Triangular';}