src/Entity/Delegation.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DelegationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassDelegationRepository::class)]
  8. class Delegation
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255)]
  15.     private $libelle;
  16.     #[ORM\OneToMany(mappedBy'delegation'targetEntityAdresse::class)]
  17.     private $adresses;
  18.     #[ORM\ManyToOne(inversedBy'delegations')]
  19.     private ?Gouvernorat $gouvernorat null;
  20.     public function __construct()
  21.     {
  22.         $this->adresses = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getLibelle(): ?string
  29.     {
  30.         return $this->libelle;
  31.     }
  32.     public function setLibelle(string $libelle): self
  33.     {
  34.         $this->libelle $libelle;
  35.         return $this;
  36.     }
  37.      public function __toString()
  38.      {
  39.          return (string)$this->getLibelle();
  40.      }
  41.     /**
  42.       * @return Collection<int, Adresse>
  43.       */
  44.     public function getAdresses(): Collection
  45.     {
  46.         return $this->adresses;
  47.     }
  48.     public function addAdress(Adresse $adress): self
  49.     {
  50.         if (!$this->adresses->contains($adress)) {
  51.             $this->adresses->add($adress);
  52.             $adress->setDelegation($this);
  53.         }
  54.         return $this;
  55.     }
  56.     public function removeAdress(Adresse $adress): self
  57.     {
  58.         if ($this->adresses->removeElement($adress)) {
  59.             // set the owning side to null (unless already changed)
  60.             if ($adress->getDelegation() === $this) {
  61.                 $adress->setDelegation(null);
  62.             }
  63.         }
  64.         return $this;
  65.     }
  66.     public function getGouvernorat(): ?Gouvernorat
  67.     {
  68.         return $this->gouvernorat;
  69.     }
  70.     public function setGouvernorat(?Gouvernorat $gouvernorat): self
  71.     {
  72.         $this->gouvernorat $gouvernorat;
  73.         return $this;
  74.     }
  75. }