src/Entity/Package.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PackageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassPackageRepository::class)]
  9. class Package
  10. {
  11.     public function __toString(): string
  12.     {
  13.         return $this->name;
  14.     }
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\OneToMany(mappedBy'package'targetEntityPackageFeatures::class, cascade: ["persist""remove"])]
  20.     protected Collection $packageFeatures;
  21.     #[ORM\Column(type'string')]
  22.     private string $name;
  23.     #[ORM\Column(type'json'nullabletrue)]
  24.     private array|null $info null;
  25.     #[ORM\Column(type'decimal')]
  26.     private ?string $price;
  27.     public function __construct()
  28.     {
  29.         $this->packageFeatures = new ArrayCollection();
  30.         $this->info = [
  31.             'type' => null,
  32.             'sub_info' => null,
  33.             'feature_info' => null,
  34.             'features' => []
  35.         ];
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getName(): ?string
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function setName(string $name): static
  46.     {
  47.         $this->name $name;
  48.         return $this;
  49.     }
  50.     public function getPrice(): ?string
  51.     {
  52.         return $this->price;
  53.     }
  54.     public function setPrice(string $price): static
  55.     {
  56.         $this->price $price;
  57.         return $this;
  58.     }
  59.     public function getPackageFeatures(): Collection
  60.     {
  61.         return $this->packageFeatures;
  62.     }
  63.     public function addPackageFeature(PackageFeatures $packageFeature): static
  64.     {
  65.         if (!$this->packageFeatures->contains($packageFeature)) {
  66.             $this->packageFeatures->add($packageFeature);
  67.             $packageFeature->setPackage($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removePackageFeature(PackageFeatures $packageFeature): static
  72.     {
  73.         if ($this->packageFeatures->removeElement($packageFeature)) {
  74.             // set the owning side to null (unless already changed)
  75.             if ($packageFeature->getPackage() === $this) {
  76.                 $packageFeature->setPackage(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81.     public function getInfo(): ?array
  82.     {
  83.         return $this->info;
  84.     }
  85.     public function setInfo(?array $info): void
  86.     {
  87.         $this->info $info;
  88.     }
  89. }