<?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_component")
* @ORM\Entity(repositoryClass="App\Repository\Slave\ProductComponentRepository")
*/
class ProductComponent
{
public function __toString(){
return $this->getName();
}
public function getCanDelete(){
if(sizeof($this->models) > 0) return false;
return true;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name", type="string", length=191)
*/
protected $name;
// ManyToMany
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Slave\ProductModel", mappedBy="components")
*/
private $models;
public function __construct()
{
$this->models = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, ProductModel>
*/
public function getModels(): Collection
{
return $this->models;
}
public function addModel(ProductModel $model): self
{
if (!$this->models->contains($model)) {
$this->models->add($model);
$model->addComponent($this);
}
return $this;
}
public function removeModel(ProductModel $model): self
{
if ($this->models->removeElement($model)) {
$model->removeComponent($this);
}
return $this;
}
}