src/Entity/Quota.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\QuotaClassification;
  4. use App\Enum\QuotaPeriodUnitType;
  5. use App\Repository\QuotaRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Timestampable\Traits\TimestampableEntity;
  11. #[ORM\Entity(repositoryClassQuotaRepository::class)]
  12. class Quota
  13. {
  14.     use TimestampableEntity;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $name null;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?QuotaPeriodUnitType $unitType null;
  23.     #[ORM\OneToMany(mappedBy'quota'targetEntityQuotaTier::class, cascade: ['persist'], orphanRemovaltrue)]
  24.     private Collection $quotaTiers;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?QuotaClassification $classification null;
  27.     #[ORM\ManyToOne]
  28.     private ?Quota $parent null;
  29.     #[ORM\ManyToOne]
  30.     private ?User $user null;
  31.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  32.     private ?\DateTimeInterface $effectiveStart null;
  33.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  34.     private ?\DateTimeInterface $effectiveEnd null;
  35.     #[ORM\ManyToOne(inversedBy'quotas')]
  36.     private ?Year $year null;
  37.     #[ORM\ManyToOne(inversedBy'quotas')]
  38.     private ?Period $period null;
  39.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  40.     private ?string $description null;
  41.     #[ORM\OneToMany(mappedBy'quota'targetEntityQuotaAssignment::class, orphanRemovaltrue)]
  42.     private Collection $quotaAssignments;
  43.     #[ORM\OneToMany(mappedBy'quota'targetEntityRuleResult::class)]
  44.     private Collection $ruleResults;
  45.     #[ORM\OneToMany(mappedBy'quota'targetEntityCommission::class)]
  46.     private Collection $commissions;
  47.     public function __construct()
  48.     {
  49.         $this->quotaTiers = new ArrayCollection();
  50.         $this->quotaAssignments = new ArrayCollection();
  51.         $this->ruleResults = new ArrayCollection();
  52.         $this->commissions = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getName(): ?string
  59.     {
  60.         return $this->name;
  61.     }
  62.     public function setName(string $name): self
  63.     {
  64.         $this->name $name;
  65.         return $this;
  66.     }
  67.     public function getUnitType(): ?QuotaPeriodUnittype
  68.     {
  69.         return $this->unitType;
  70.     }
  71.     public function setUnitType(?QuotaPeriodUnitType $unitType): self
  72.     {
  73.         $this->unitType $unitType;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Collection<int, QuotaTier>
  78.      */
  79.     public function getQuotaTiers(): Collection
  80.     {
  81.         return $this->quotaTiers;
  82.     }
  83.     public function addQuotaTier(QuotaTier $quotaTier): self
  84.     {
  85.         if (!$this->quotaTiers->contains($quotaTier)) {
  86.             $this->quotaTiers->add($quotaTier);
  87.             $quotaTier->setQuota($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeQuotaTier(QuotaTier $quotaTier): self
  92.     {
  93.         if ($this->quotaTiers->removeElement($quotaTier)) {
  94.             // set the owning side to null (unless already changed)
  95.             if ($quotaTier->getQuota() === $this) {
  96.                 $quotaTier->setQuota(null);
  97.             }
  98.         }
  99.         return $this;
  100.     }
  101.     public function getClassification(): ?QuotaClassification
  102.     {
  103.         return $this->classification;
  104.     }
  105.     public function setClassification(?QuotaClassification $classification): self
  106.     {
  107.         $this->classification $classification;
  108.         return $this;
  109.     }
  110.     public function getUser() : ?User
  111.     {
  112.         return $this->user;
  113.     }
  114.     public function setUser(?User $user): self
  115.     {
  116.         $this->user $user;
  117.         return $this;
  118.     }
  119.     public function getParent() : ?Quota
  120.     {
  121.         return $this->parent;
  122.     }
  123.     public function setParent(?Quota $parent): self
  124.     {
  125.         $this->parent $parent;
  126.         return $this;
  127.     }
  128.     public function getEffectiveStart(): ?\DateTimeInterface
  129.     {
  130.         return $this->effectiveStart;
  131.     }
  132.     public function setEffectiveStart(?\DateTimeInterface $effectiveStart): self
  133.     {
  134.         $this->effectiveStart $effectiveStart;
  135.         return $this;
  136.     }
  137.     public function getEffectiveEnd(): ?\DateTimeInterface
  138.     {
  139.         return $this->effectiveEnd;
  140.     }
  141.     public function setEffectiveEnd(?\DateTimeInterface $effectiveEnd): self
  142.     {
  143.         $this->effectiveEnd $effectiveEnd;
  144.         return $this;
  145.     }
  146.     public function __toString()
  147.     {
  148.         return $this->name;
  149.     }
  150.     public function getYear(): ?Year
  151.     {
  152.         return $this->year;
  153.     }
  154.     public function setYear(?Year $year): self
  155.     {
  156.         $this->year $year;
  157.         return $this;
  158.     }
  159.     public function getPeriod(): ?Period
  160.     {
  161.         return $this->period;
  162.     }
  163.     public function setPeriod(?Period $period): self
  164.     {
  165.         $this->period $period;
  166.         return $this;
  167.     }
  168.     public function getDescription(): ?string
  169.     {
  170.         return $this->description;
  171.     }
  172.     public function setDescription(?string $description): self
  173.     {
  174.         $this->description $description;
  175.         return $this;
  176.     }
  177.     /**
  178.      * @return Collection<int, QuotaAssignment>
  179.      */
  180.     public function getQuotaAssignments(): Collection
  181.     {
  182.         return $this->quotaAssignments;
  183.     }
  184.     public function addQuotaAssignment(QuotaAssignment $quotaAssignment): self
  185.     {
  186.         if (!$this->quotaAssignments->contains($quotaAssignment)) {
  187.             $this->quotaAssignments->add($quotaAssignment);
  188.             $quotaAssignment->setQuota($this);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeQuotaAssignment(QuotaAssignment $quotaAssignment): self
  193.     {
  194.         if ($this->quotaAssignments->removeElement($quotaAssignment)) {
  195.             // set the owning side to null (unless already changed)
  196.             if ($quotaAssignment->getQuota() === $this) {
  197.                 $quotaAssignment->setQuota(null);
  198.             }
  199.         }
  200.         return $this;
  201.     }
  202.     /**
  203.      * @return Collection<int, RuleResult>
  204.      */
  205.     public function getRuleResults(): Collection
  206.     {
  207.         return $this->ruleResults;
  208.     }
  209.     public function addRuleResult(RuleResult $ruleResult): static
  210.     {
  211.         if (!$this->ruleResults->contains($ruleResult)) {
  212.             $this->ruleResults->add($ruleResult);
  213.             $ruleResult->setQuota($this);
  214.         }
  215.         return $this;
  216.     }
  217.     public function removeRuleResult(RuleResult $ruleResult): static
  218.     {
  219.         if ($this->ruleResults->removeElement($ruleResult)) {
  220.             // set the owning side to null (unless already changed)
  221.             if ($ruleResult->getQuota() === $this) {
  222.                 $ruleResult->setQuota(null);
  223.             }
  224.         }
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return Collection<int, Commission>
  229.      */
  230.     public function getCommissions(): Collection
  231.     {
  232.         return $this->commissions;
  233.     }
  234.     public function addCommission(Commission $commission): static
  235.     {
  236.         if (!$this->commissions->contains($commission)) {
  237.             $this->commissions->add($commission);
  238.             $commission->setQuota($this);
  239.         }
  240.         return $this;
  241.     }
  242.     public function removeCommission(Commission $commission): static
  243.     {
  244.         if ($this->commissions->removeElement($commission)) {
  245.             // set the owning side to null (unless already changed)
  246.             if ($commission->getQuota() === $this) {
  247.                 $commission->setQuota(null);
  248.             }
  249.         }
  250.         return $this;
  251.     }
  252. }