src/Flexy/ShopBundle/Entity/Product/ProductVariant.php line 13
<?php
namespace App\Flexy\ShopBundle\Entity\Product;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Repository\Product\ProductVariantRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: ProductVariantRepository::class)]
class ProductVariant
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $name = null;
#[ORM\ManyToMany(targetEntity: AttributValue::class, inversedBy: 'productVariants')]
private \Doctrine\Common\Collections\Collection|array $attributeValues;
#[ORM\ManyToOne(targetEntity: Product::class, inversedBy: 'productVariants', cascade: ['persist'])]
private ?\App\Flexy\ShopBundle\Entity\Product\Product $product = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $quantity = null;
#[ORM\Column(type: 'float')]
private ?float $price = null;
public function __construct()
{
$this->attributeValues = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|AttributValue[]
*/
public function getAttributeValues(): Collection
{
return $this->attributeValues;
}
public function addAttributeValue(AttributValue $attributeValue): self
{
if (!$this->attributeValues->contains($attributeValue)) {
$this->attributeValues[] = $attributeValue;
}
return $this;
}
public function removeAttributeValue(AttributValue $attributeValue): self
{
$this->attributeValues->removeElement($attributeValue);
return $this;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): self
{
$this->product = $product;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(?int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): self
{
$this->price = $price;
return $this;
}
}