src/Entity/Agency.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AgencyRepository;
  4. use App\Repository\ConfigurationRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassAgencyRepository::class)]
  9. #[ORM\Table(name'tb_agencies')]
  10. #[ORM\HasLifecycleCallbacks]
  11. class Agency
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type"string"uniquetrue)]
  15.     private ?string $id;
  16.     #[ORM\Column(length50uniquetrue)]
  17.     private ?string $code;
  18.     #[ORM\Column(length50uniquetrue)]
  19.     private ?string $name;
  20.     #[ORM\Column(type'boolean'nullabletrue)]
  21.     private ?bool $headOffice;
  22.     #[ORM\Column(type'datetime'nullablefalse)]
  23.     private ?\DateTimeInterface $createdAt;
  24.     #[ORM\Column(type'datetime'nullabletrue)]
  25.     private ?\DateTimeInterface $modifiedAt;
  26.     #[ORM\Column(type'boolean'nullablefalse)]
  27.     private ?bool $activated;
  28.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'agencies')]
  29.     private ?User $createdBy;
  30.     #[ORM\OneToMany(mappedBy'agency'targetEntityAgencyAccount::class)]
  31.     private ?Collection $agencyAccounts;
  32.     #[ORM\OneToMany(mappedBy'agency'targetEntityAgencyExtension::class)]
  33.     private ?Collection $agencyExtensions;
  34.     #[ORM\OneToMany(mappedBy'startingAgency'targetEntityTransfert::class)]
  35.     private Collection $transferts;
  36.     public function __construct()
  37.     {
  38.         $this->agencyAccounts = new ArrayCollection();
  39.         $this->agencyExtensions = new ArrayCollection();
  40.         $this->createdAt = new \DateTime();
  41.         $this->transferts = new ArrayCollection();
  42.     }
  43.     public function getId(): ?string
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function setId(string $id): self
  48.     {
  49.         $this->id $id;
  50.         return $this;
  51.     }
  52.     public function getCode(): ?string
  53.     {
  54.         return $this->code;
  55.     }
  56.     public function setCode(string $code): self
  57.     {
  58.         $this->code $code;
  59.         return $this;
  60.     }
  61.     public function getName(): ?string
  62.     {
  63.         return $this->name;
  64.     }
  65.     public function setName(string $name): self
  66.     {
  67.         $this->name $name;
  68.         return $this;
  69.     }
  70.     public function getHeadOffice(): ?bool
  71.     {
  72.         return $this->headOffice;
  73.     }
  74.     public function setHeadOffice(?bool $headOffice): self
  75.     {
  76.         $this->headOffice $headOffice;
  77.         return $this;
  78.     }
  79.     public function getCreatedAt(): ?\DateTimeInterface
  80.     {
  81.         return $this->createdAt;
  82.     }
  83.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  84.     {
  85.         $this->createdAt $createdAt;
  86.         return $this;
  87.     }
  88.     public function getModifiedAt(): ?\DateTimeInterface
  89.     {
  90.         return $this->modifiedAt;
  91.     }
  92.     public function setModifiedAt(?\DateTimeInterface $modifiedAt): self
  93.     {
  94.         $this->modifiedAt $modifiedAt;
  95.         return $this;
  96.     }
  97.     public function getActivated(): ?bool
  98.     {
  99.         return $this->activated;
  100.     }
  101.     public function setActivated(?bool $activated): self
  102.     {
  103.         $this->activated $activated;
  104.         return $this;
  105.     }
  106.     public function getCreatedBy(): ?User
  107.     {
  108.         return $this->createdBy;
  109.     }
  110.     public function setCreatedBy(?User $createdBy): self
  111.     {
  112.         $this->createdBy $createdBy;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection|AgencyAccount[]
  117.      */
  118.     public function getAgencyAccounts(): Collection
  119.     {
  120.         return $this->agencyAccounts;
  121.     }
  122.     public function addAgencyAccount(AgencyAccount $agencyAccount): self
  123.     {
  124.         if (!$this->agencyAccounts->contains($agencyAccount)) {
  125.             $this->agencyAccounts[] = $agencyAccount;
  126.             $agencyAccount->setAgency($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeAgencyAccount(AgencyAccount $agencyAccount): self
  131.     {
  132.         if ($this->agencyAccounts->removeElement($agencyAccount)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($agencyAccount->getAgency() === $this) {
  135.                 $agencyAccount->setAgency(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140.     /**
  141.      * @return Collection|AgencyExtension[]
  142.      */
  143.     public function getAgencyExtensions(): Collection
  144.     {
  145.         return $this->agencyExtensions;
  146.     }
  147.     public function addAgencyExtension(AgencyExtension $agencyExtension): self
  148.     {
  149.         if (!$this->agencyExtensions->contains($agencyExtension)) {
  150.             $this->agencyExtensions[] = $agencyExtension;
  151.             $agencyExtension->setAgency($this);
  152.         }
  153.         return $this;
  154.     }
  155.     public function removeAgencyExtension(AgencyExtension $agencyExtension): self
  156.     {
  157.         if ($this->agencyExtensions->removeElement($agencyExtension)) {
  158.             // set the owning side to null (unless already changed)
  159.             if ($agencyExtension->getAgency() === $this) {
  160.                 $agencyExtension->setAgency(null);
  161.             }
  162.         }
  163.         return $this;
  164.     }
  165.     #[ORM\PreUpdate]
  166.     public function onUpdate() {
  167.         $this->modifiedAt = new \DateTime();
  168.     }
  169.     /**
  170.      * @return Collection<int, Transfert>
  171.      */
  172.     public function getTransferts(): Collection
  173.     {
  174.         return $this->transferts;
  175.     }
  176.     public function addTransfert(Transfert $transfert): static
  177.     {
  178.         if (!$this->transferts->contains($transfert)) {
  179.             $this->transferts->add($transfert);
  180.             $transfert->setStartingAgency($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeTransfert(Transfert $transfert): static
  185.     {
  186.         if ($this->transferts->removeElement($transfert)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($transfert->getStartingAgency() === $this) {
  189.                 $transfert->setStartingAgency(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194. }