<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_product_condition")
* @ORM\Entity
*/
class ProductCondition
{
public function isStatusAvailable(){
if($this->getSlug() == 'new' || $this->getSlug() == 'refurbished' || $this->getSlug() == 'repaired' || $this->getSlug() == 'free' || $this->getSlug() == 'regenerated')
return true;
return false;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="slug", type="string", unique=true, length=191)
*/
protected $slug;
/**
* @ORM\Column(name="value", type="string", length=191)
*/
protected $value;
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\Product", mappedBy="condition")
*/
private $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products->add($product);
$product->setCondition($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getCondition() === $this) {
$product->setCondition(null);
}
}
return $this;
}
}