src/Entity/Affiliate.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AffiliateRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @Vich\Uploadable
  14.  */
  15. #[ORM\Entity(repositoryClassAffiliateRepository::class)]
  16. class Affiliate
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     private $id;
  22.     #[ORM\Column(type'string'length255)]
  23.     private $name;
  24.     #[ORM\Column(type'string'length255)]
  25.     private $code;
  26.     #[ORM\OneToMany(mappedBy'affiliate'targetEntityAccountingFirm::class)]
  27.     private $accountingFirms;
  28.     /**
  29.      * @Vich\UploadableField(mapping="podcast_middle_file", fileNameProperty="contractFilename")
  30.      * @var File|null
  31.      */
  32.     private ?File $contractFile null;
  33.     #[ORM\Column(nullabletrue)]
  34.     private ?string $contractFilename null;
  35.     #[ORM\Column(type'datetime_immutable')]
  36.     private ?DateTimeImmutable $updateAt;
  37.     #[ORM\OneToMany(mappedBy'affiliate'targetEntityAffiliateRequest::class)]
  38.     private $affiliateRequests;
  39.     #[ORM\OneToMany(mappedBy'affiliate'targetEntityAffiliateClient::class)]
  40.     private $affiliateClients;
  41.     #[ORM\OneToMany(mappedBy'affiliate'targetEntityUser::class, cascade: ['remove'])]
  42.     private $users;
  43.     #[ORM\Column(type'string'length50nullabletrue)]
  44.     private $primaryColor;
  45.     #[ORM\Column(type'string'length50nullabletrue)]
  46.     private $secondaryColor;
  47.     public function __construct()
  48.     {
  49.         $this->accountingFirms = new ArrayCollection();
  50.         $this->affiliateRequests = new ArrayCollection();
  51.         $this->affiliateClients = new ArrayCollection();
  52.         $this->users = new ArrayCollection();
  53.     }
  54.     public function __toString(): string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getName(): ?string
  63.     {
  64.         return $this->name;
  65.     }
  66.     public function setName(string $name): self
  67.     {
  68.         $this->name $name;
  69.         return $this;
  70.     }
  71.     public function getCode(): ?string
  72.     {
  73.         return $this->code;
  74.     }
  75.     public function setCode(string $code): self
  76.     {
  77.         $this->code $code;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, AccountingFirm>
  82.      */
  83.     public function getAccountingFirms(): Collection
  84.     {
  85.         return $this->accountingFirms;
  86.     }
  87.     public function addAccountingFirm(AccountingFirm $accountingFirm): self
  88.     {
  89.         if (!$this->accountingFirms->contains($accountingFirm)) {
  90.             $this->accountingFirms[] = $accountingFirm;
  91.             $accountingFirm->setAffiliate($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeAccountingFirm(AccountingFirm $accountingFirm): self
  96.     {
  97.         if ($this->accountingFirms->removeElement($accountingFirm)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($accountingFirm->getAffiliate() === $this) {
  100.                 $accountingFirm->setAffiliate(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     /**
  106.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  107.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  108.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  109.      * must be able to accept an instance of 'File' as the bundle will inject one here
  110.      * during Doctrine hydration.
  111.      *
  112.      * @param File|UploadedFile|null $imageFile
  113.      */
  114.     public function setContractFile(?File $contractFile null): void
  115.     {
  116.         $this->contractFile $contractFile;
  117.         if (null !== $contractFile) {
  118.             // It is required that at least one field changes if you are using doctrine
  119.             // otherwise the event listeners won't be called and the file is lost
  120.             $this->updateAt = new DateTimeImmutable();
  121.         }
  122.     }
  123.     public function getContractFile(): ?File
  124.     {
  125.         return $this->contractFile;
  126.     }
  127.     public function setContractFileName(?string $contractFilename): void
  128.     {
  129.         $this->contractFilename $contractFilename;
  130.     }
  131.     public function getContractFileName(): ?string
  132.     {
  133.         return $this->contractFilename;
  134.     }
  135.     public function getUpdateAt(): ?DateTimeImmutable
  136.     {
  137.         return $this->updateAt;
  138.     }
  139.     public function setUpdateAt(DateTimeImmutable $updateAt): self
  140.     {
  141.         $this->updateAt $updateAt;
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return Collection<int, AffiliateRequest>
  146.      */
  147.     public function getAffiliateRequests(): Collection
  148.     {
  149.         return $this->affiliateRequests;
  150.     }
  151.     public function addAffiliateRequest(AffiliateRequest $affiliateRequest): self
  152.     {
  153.         if (!$this->affiliateRequests->contains($affiliateRequest)) {
  154.             $this->affiliateRequests[] = $affiliateRequest;
  155.             $affiliateRequest->setAffiliate($this);
  156.         }
  157.         return $this;
  158.     }
  159.     public function removeAffiliateRequest(AffiliateRequest $affiliateRequest): self
  160.     {
  161.         if ($this->affiliateRequests->removeElement($affiliateRequest)) {
  162.             // set the owning side to null (unless already changed)
  163.             if ($affiliateRequest->getAffiliate() === $this) {
  164.                 $affiliateRequest->setAffiliate(null);
  165.             }
  166.         }
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, AffiliateClient>
  171.      */
  172.     public function getAffiliateClients(): Collection
  173.     {
  174.         return $this->affiliateClients;
  175.     }
  176.     public function addAffiliateClient(AffiliateClient $affiliateClient): self
  177.     {
  178.         if (!$this->affiliateClients->contains($affiliateClient)) {
  179.             $this->affiliateClients[] = $affiliateClient;
  180.             $affiliateClient->setAffiliate($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeAffiliateClient(AffiliateClient $affiliateClient): self
  185.     {
  186.         if ($this->affiliateClients->removeElement($affiliateClient)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($affiliateClient->getAffiliate() === $this) {
  189.                 $affiliateClient->setAffiliate(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return Collection<int, User>
  196.      */
  197.     public function getUsers(): Collection
  198.     {
  199.         return $this->users;
  200.     }
  201.     public function addUser(User $user): self
  202.     {
  203.         if (!$this->users->contains($user)) {
  204.             $this->users[] = $user;
  205.             $user->setAffiliate($this);
  206.         }
  207.         return $this;
  208.     }
  209.     public function removeUser(User $user): self
  210.     {
  211.         if ($this->users->removeElement($user)) {
  212.             // set the owning side to null (unless already changed)
  213.             if ($user->getAffiliate() === $this) {
  214.                 $user->setAffiliate(null);
  215.             }
  216.         }
  217.         return $this;
  218.     }
  219.     /**
  220.      * @return string
  221.      */
  222.     public function getPrimaryColor(): ?string
  223.     {
  224.         return $this->primaryColor;
  225.     }
  226.     /**
  227.      * @param string $primaryColor
  228.      * @return Affiliate
  229.      */
  230.     public function setPrimaryColor(?string $primaryColor): Affiliate
  231.     {
  232.         $this->primaryColor $primaryColor;
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return string
  237.      */
  238.     public function getSecondaryColor(): ?string
  239.     {
  240.         return $this->secondaryColor;
  241.     }
  242.     /**
  243.      * @param string $secondaryColor
  244.      * @return Affiliate
  245.      */
  246.     public function setSecondaryColor(?string $secondaryColor): Affiliate
  247.     {
  248.         $this->secondaryColor $secondaryColor;
  249.         return $this;
  250.     }
  251. }