<?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_termid")
* @ORM\Entity
*/
class Termid
{
public function __toString(){
return $this->getCode();
}
public function displayProducts()
{
$html = '';
$first = true;
foreach($this->products as $product){
if($first) $first = false; else $html.= '<br>';
$html.= $product->getModel().' --- Codice produttore: '.$product->getCodeProducer().' --- Codice fornitore: '.$product->getCodeSupplier();
}
return $html;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="code", type="string", length=191)
*/
protected $code;
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\Product", mappedBy="termid")
*/
private $products;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="termid")
*/
private $tickets;
//
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Slave\Client", inversedBy="termids")
* @ORM\JoinColumn(name="client_id", referencedColumnName="id")
*/
private $client;
//
public function __construct()
{
$this->products = new ArrayCollection();
$this->tickets = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
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->setTermid($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->getTermid() === $this) {
$product->setTermid(null);
}
}
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
/**
* @return Collection<int, Ticket>
*/
public function getTickets(): Collection
{
return $this->tickets;
}
public function addTicket(Ticket $ticket): self
{
if (!$this->tickets->contains($ticket)) {
$this->tickets->add($ticket);
$ticket->setTermid($this);
}
return $this;
}
public function removeTicket(Ticket $ticket): self
{
if ($this->tickets->removeElement($ticket)) {
// set the owning side to null (unless already changed)
if ($ticket->getTermid() === $this) {
$ticket->setTermid(null);
}
}
return $this;
}
}