src/Entity/CommercialSaleZone.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommercialSaleZoneRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCommercialSaleZoneRepository::class)]
  8. class CommercialSaleZone
  9. {
  10.     use IdentifiableTrait;
  11.     #[ORM\Column(length255)]
  12.     private ?string $name null;
  13.     #[ORM\Column(length5nullabletrue)]
  14.     private ?string $number null;
  15.     #[ORM\Column]
  16.     private ?int $position null;
  17.     #[ORM\ManyToMany(targetEntityCommercial::class, mappedBy'saleZones')]
  18.     private Collection $commercials;
  19.     public function __construct()
  20.     {
  21.         $this->commercials = new ArrayCollection();
  22.     }
  23.     public function __toString(): string
  24.     {
  25.         return $this->name ' (' $this->number ')';
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getName(): ?string
  32.     {
  33.         return $this->name;
  34.     }
  35.     public function setName(string $name): self
  36.     {
  37.         $this->name $name;
  38.         return $this;
  39.     }
  40.     public function getPosition(): ?int
  41.     {
  42.         return $this->position;
  43.     }
  44.     public function setPosition(int $position): self
  45.     {
  46.         $this->position $position;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Commercial>
  51.      */
  52.     public function getCommercials(): Collection
  53.     {
  54.         return $this->commercials;
  55.     }
  56.     public function addCommercial(Commercial $commercial): self
  57.     {
  58.         if (!$this->commercials->contains($commercial)) {
  59.             $this->commercials->add($commercial);
  60.             $commercial->addSaleZone($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeCommercial(Commercial $commercial): self
  65.     {
  66.         if ($this->commercials->removeElement($commercial)) {
  67.             $commercial->removeSaleZone($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function getNumber(): ?string
  72.     {
  73.         return $this->number;
  74.     }
  75.     public function setNumber(?string $number): self
  76.     {
  77.         $this->number $number;
  78.         return $this;
  79.     }
  80. }