src/Entity/RateTableAssignment.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\RateTableAssignmentType;
  4. use App\Repository\RateTableAssignmentRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassRateTableAssignmentRepository::class)]
  10. class RateTableAssignment
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\ManyToOne(inversedBy'rateTableAssignments')]
  18.     private ?RateTable $rateTable null;
  19.     #[ORM\ManyToOne(inversedBy'rateTableAssignments'fetch'EAGER')]
  20.     private ?User $user null;
  21.     #[ORM\ManyToOne(inversedBy'rateTableAssignments'fetch'EAGER')]
  22.     private ?Title $title null;
  23.     #[ORM\Column(length255)]
  24.     private ?RateTableAssignmentType $type null;
  25.     #[ORM\OneToMany(mappedBy'rateTableAssignment'targetEntityRateTableTier::class, cascade: ['persist''remove'])]
  26.     #[ORM\OrderBy(['low' => 'ASC'])]
  27.     private Collection $rateTableTiers;
  28.     public function __construct()
  29.     {
  30.         $this->rateTableTiers = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getRateTable(): ?RateTable
  37.     {
  38.         return $this->rateTable;
  39.     }
  40.     public function setRateTable(?RateTable $rateTable): static
  41.     {
  42.         $this->rateTable $rateTable;
  43.         return $this;
  44.     }
  45.     public function getUser(): ?User
  46.     {
  47.         return $this->user;
  48.     }
  49.     public function setUser(?User $user): static
  50.     {
  51.         $this->user $user;
  52.         return $this;
  53.     }
  54.     public function getTitle(): ?Title
  55.     {
  56.         return $this->title;
  57.     }
  58.     public function setTitle(?Title $title): static
  59.     {
  60.         $this->title $title;
  61.         return $this;
  62.     }
  63.     public function getType(): ?RateTableAssignmentType
  64.     {
  65.         return $this->type;
  66.     }
  67.     public function setType(RateTableAssignmentType $type): static
  68.     {
  69.         $this->type $type;
  70.         return $this;
  71.     }
  72.     public function __toString(): string
  73.     {
  74.         return (string)$this->type->name;
  75.     }
  76.     /**
  77.      * @return Collection<int, RateTableTier>
  78.      */
  79.     public function getRateTableTiers(): Collection
  80.     {
  81.         return $this->rateTableTiers;
  82.     }
  83.     public function addRateTableTier(RateTableTier $rateTableTier): static
  84.     {
  85.         if (!$this->rateTableTiers->contains($rateTableTier)) {
  86.             $this->rateTableTiers->add($rateTableTier);
  87.             $rateTableTier->setRateTableAssignment($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeRateTableTier(RateTableTier $rateTableTier): static
  92.     {
  93.         if ($this->rateTableTiers->removeElement($rateTableTier)) {
  94.             // set the owning side to null (unless already changed)
  95.             if ($rateTableTier->getRateTableAssignment() === $this) {
  96.                 $rateTableTier->setRateTableAssignment(null);
  97.             }
  98.         }
  99.         return $this;
  100.     }
  101. }