src/Entity/PackageCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PackageCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Traits\CreatedUpdatedTrait;
  8. /**
  9.  * @ORM\Table(name="v_package_category")
  10.  * @ORM\Entity(repositoryClass=PackageCategoryRepository::class)
  11.  */
  12. class PackageCategory
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="text", nullable=true)
  26.      */
  27.     private $description;
  28.     /**
  29.      * @ORM\OneToMany(targetEntity=Package::class, mappedBy="category")
  30.      */
  31.     private $packages;
  32.     
  33.     use CreatedUpdatedTrait;
  34.     public function __construct()
  35.     {
  36.         $this->packages = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     public function getDescription(): ?string
  52.     {
  53.         return $this->description;
  54.     }
  55.     public function setDescription(?string $description): self
  56.     {
  57.         $this->description $description;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Package>
  62.      */
  63.     public function getPackages(): Collection
  64.     {
  65.         return $this->packages;
  66.     }
  67.     public function addPackage(Package $package): self
  68.     {
  69.         if (!$this->packages->contains($package)) {
  70.             $this->packages[] = $package;
  71.             $package->setCategory($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removePackage(Package $package): self
  76.     {
  77.         if ($this->packages->removeElement($package)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($package->getCategory() === $this) {
  80.                 $package->setCategory(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85. }