src/Entity/Attribute.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AttributeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=AttributeRepository::class)
  9.  */
  10. class Attribute
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private ?int $id null;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=Model::class, inversedBy="attributes")
  20.      */
  21.     private $model;
  22.     /**
  23.      * @ORM\Column(type="string", length=64)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="integer", length=16)
  28.      */
  29.     private $wttId;
  30.     /**
  31.      * @ORM\Column(type="string", length=128)
  32.      */
  33.     private $value;
  34.     /**
  35.      * @ORM\Column(type="string", length=128)
  36.      */
  37.     private $price;
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity=Cart::class, inversedBy="attributes", cascade={"persist"})
  40.      * @ORM\JoinColumn(nullable=false)
  41.      */
  42.     private $cart;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=Option::class, mappedBy="attribute")
  45.      */
  46.     private $options;
  47.     public function __construct()
  48.     {
  49.         $this->cart = new ArrayCollection();
  50.         $this->options = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getWttId(): ?int
  57.     {
  58.         return $this->wttId;
  59.     }
  60.     public function setWttId(int $wttId): static
  61.     {
  62.         $this->wttId $wttId;
  63.         return $this;
  64.     }
  65.     public function getValue(): ?string
  66.     {
  67.         return $this->value;
  68.     }
  69.     public function setValue(string $value): static
  70.     {
  71.         $this->value $value;
  72.         return $this;
  73.     }
  74.     public function getModel(): ?Model
  75.     {
  76.         return $this->model;
  77.     }
  78.     public function setModel(?Model $model): static
  79.     {
  80.         $this->model $model;
  81.         return $this;
  82.     }
  83.     public function getName(): ?string
  84.     {
  85.         return $this->name;
  86.     }
  87.     public function setName(string $name): static
  88.     {
  89.         $this->name $name;
  90.         return $this;
  91.     }
  92.     public function getPrice(): ?string
  93.     {
  94.         return $this->price;
  95.     }
  96.     public function setPrice(string $price): static
  97.     {
  98.         $this->price $price;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return Collection<int, Cart>
  103.      */
  104.     public function getCart(): Collection
  105.     {
  106.         return $this->cart;
  107.     }
  108.     public function addCart(Cart $cart): static
  109.     {
  110.         if (!$this->cart->contains($cart)) {
  111.             $this->cart->add($cart);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeCart(Cart $cart): static
  116.     {
  117.         $this->cart->removeElement($cart);
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, Option>
  122.      */
  123.     public function getOptions(): Collection
  124.     {
  125.         return $this->options;
  126.     }
  127.     public function addOption(Option $option): static
  128.     {
  129.         if (!$this->options->contains($option)) {
  130.             $this->options->add($option);
  131.             $option->setAttribute($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeOption(Option $option): static
  136.     {
  137.         if ($this->options->removeElement($option)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($option->getAttribute() === $this) {
  140.                 $option->setAttribute(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145. }