src/Entity/CourseLicense.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\CourseLicenseRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\UX\Turbo\Attribute\Broadcast;
  10. #[ORM\Entity(repositoryClassCourseLicenseRepository::class)]
  11. #[ApiResource]
  12. #[Broadcast]
  13. class CourseLicense
  14. {
  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(typeTypes::TEXT)]
  22.     private ?string $description null;
  23.     #[ORM\ManyToMany(targetEntityCourse::class, inversedBy'courseLicenses')]
  24.     private Collection $courses;
  25.     #[ORM\OneToMany(mappedBy'courseLicense'targetEntityLicensePrice::class, cascade: ['persist'])]
  26.     private Collection $licensePrices;
  27.     #[ORM\Column]
  28.     private ?float $basePrice null;
  29.     #[ORM\ManyToOne(inversedBy'courseLicenses')]
  30.     private ?Catalog $catalog null;
  31.     #[ORM\OneToMany(mappedBy'courseLicense'targetEntityLicenseStatus::class)]
  32.     private Collection $licenseStatuses;
  33.     #[ORM\OneToMany(mappedBy'courseLicense'targetEntityCorporationDiscount::class)]
  34.     private Collection $corporationDiscounts;
  35.     #[ORM\OneToMany(mappedBy'course'targetEntityAddOn::class)]
  36.     private Collection $addOns;
  37.     public function __construct()
  38.     {
  39.         $this->courses = new ArrayCollection();
  40.         $this->licensePrices = new ArrayCollection();
  41.         $this->setDescription('Beschreibung');
  42.         $this->licenseStatuses = new ArrayCollection();
  43.         $this->corporationDiscounts = new ArrayCollection();
  44.         $this->addOns = new ArrayCollection();
  45.     }
  46.     public function __toString(): string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getDescription(): ?string
  64.     {
  65.         return $this->description;
  66.     }
  67.     public function setDescription(string $description): self
  68.     {
  69.         $this->description $description;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Course>
  74.      */
  75.     public function getCourses(): Collection
  76.     {
  77.         return $this->courses;
  78.     }
  79.     public function addCourse(Course $course): self
  80.     {
  81.         if (!$this->courses->contains($course)) {
  82.             $this->courses->add($course);
  83.         }
  84.         return $this;
  85.     }
  86.     public function removeCourse(Course $course): self
  87.     {
  88.         $this->courses->removeElement($course);
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, LicensePrice>
  93.      */
  94.     public function getLicensePrices(): Collection
  95.     {
  96.         return $this->licensePrices;
  97.     }
  98.     public function addLicensePrice(LicensePrice $licensePrice): self
  99.     {
  100.         if (!$this->licensePrices->contains($licensePrice)) {
  101.             $this->licensePrices->add($licensePrice);
  102.             $licensePrice->setCourseLicense($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeLicensePrice(LicensePrice $licensePrice): self
  107.     {
  108.         if ($this->licensePrices->removeElement($licensePrice)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($licensePrice->getCourseLicense() === $this) {
  111.                 $licensePrice->setCourseLicense(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     public function getBasePrice(): ?float
  117.     {
  118.         return $this->basePrice;
  119.     }
  120.     public function setBasePrice(float $basePrice): self
  121.     {
  122.         $this->basePrice $basePrice;
  123.         return $this;
  124.     }
  125.     public function getCatalog(): ?Catalog
  126.     {
  127.         return $this->catalog;
  128.     }
  129.     public function setCatalog(?Catalog $catalog): self
  130.     {
  131.         $this->catalog $catalog;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return Collection<int, LicenseStatus>
  136.      */
  137.     public function getLicenseStatuses(): Collection
  138.     {
  139.         return $this->licenseStatuses;
  140.     }
  141.     public function addLicenseStatus(LicenseStatus $licenseStatus): self
  142.     {
  143.         if (!$this->licenseStatuses->contains($licenseStatus)) {
  144.             $this->licenseStatuses->add($licenseStatus);
  145.             $licenseStatus->setCourseLicense($this);
  146.         }
  147.         return $this;
  148.     }
  149.     public function removeLicenseStatus(LicenseStatus $licenseStatus): self
  150.     {
  151.         if ($this->licenseStatuses->removeElement($licenseStatus)) {
  152.             // set the owning side to null (unless already changed)
  153.             if ($licenseStatus->getCourseLicense() === $this) {
  154.                 $licenseStatus->setCourseLicense(null);
  155.             }
  156.         }
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, CorporationDiscount>
  161.      */
  162.     public function getCorporationDiscounts(): Collection
  163.     {
  164.         return $this->corporationDiscounts;
  165.     }
  166.     public function addCorporationDiscount(CorporationDiscount $corporationDiscount): self
  167.     {
  168.         if (!$this->corporationDiscounts->contains($corporationDiscount)) {
  169.             $this->corporationDiscounts->add($corporationDiscount);
  170.             $corporationDiscount->setCourseLicense($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeCorporationDiscount(CorporationDiscount $corporationDiscount): self
  175.     {
  176.         if ($this->corporationDiscounts->removeElement($corporationDiscount)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($corporationDiscount->getCourseLicense() === $this) {
  179.                 $corporationDiscount->setCourseLicense(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, AddOn>
  186.      */
  187.     public function getAddOns(): Collection
  188.     {
  189.         return $this->addOns;
  190.     }
  191.     public function addAddOn(AddOn $addOn): self
  192.     {
  193.         if (!$this->addOns->contains($addOn)) {
  194.             $this->addOns->add($addOn);
  195.             $addOn->setCourse($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeAddOn(AddOn $addOn): self
  200.     {
  201.         if ($this->addOns->removeElement($addOn)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($addOn->getCourse() === $this) {
  204.                 $addOn->setCourse(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209. }