<?php
namespace App\Entity;
use App\Repository\AttributeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=AttributeRepository::class)
*/
class Attribute
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Model::class, inversedBy="attributes")
*/
private $model;
/**
* @ORM\Column(type="string", length=64)
*/
private $name;
/**
* @ORM\Column(type="integer", length=16)
*/
private $wttId;
/**
* @ORM\Column(type="string", length=128)
*/
private $value;
/**
* @ORM\Column(type="string", length=128)
*/
private $price;
/**
* @ORM\ManyToMany(targetEntity=Cart::class, inversedBy="attributes", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
*/
private $cart;
/**
* @ORM\OneToMany(targetEntity=Option::class, mappedBy="attribute")
*/
private $options;
public function __construct()
{
$this->cart = new ArrayCollection();
$this->options = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getWttId(): ?int
{
return $this->wttId;
}
public function setWttId(int $wttId): static
{
$this->wttId = $wttId;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): static
{
$this->value = $value;
return $this;
}
public function getModel(): ?Model
{
return $this->model;
}
public function setModel(?Model $model): static
{
$this->model = $model;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getPrice(): ?string
{
return $this->price;
}
public function setPrice(string $price): static
{
$this->price = $price;
return $this;
}
/**
* @return Collection<int, Cart>
*/
public function getCart(): Collection
{
return $this->cart;
}
public function addCart(Cart $cart): static
{
if (!$this->cart->contains($cart)) {
$this->cart->add($cart);
}
return $this;
}
public function removeCart(Cart $cart): static
{
$this->cart->removeElement($cart);
return $this;
}
/**
* @return Collection<int, Option>
*/
public function getOptions(): Collection
{
return $this->options;
}
public function addOption(Option $option): static
{
if (!$this->options->contains($option)) {
$this->options->add($option);
$option->setAttribute($this);
}
return $this;
}
public function removeOption(Option $option): static
{
if ($this->options->removeElement($option)) {
// set the owning side to null (unless already changed)
if ($option->getAttribute() === $this) {
$option->setAttribute(null);
}
}
return $this;
}
}