src/Entity/Slave/Termid.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_termid")
  9.  * @ORM\Entity
  10.  */
  11. class Termid
  12. {        
  13.     public function __toString(){
  14.         return $this->getCode();
  15.     }
  16.     
  17.     public function displayProducts()
  18.     {
  19.         $html '';
  20.         $first true;
  21.         foreach($this->products as $product){
  22.             if($first$first false; else $html.= '<br>';
  23.             $html.= $product->getModel().' --- Codice produttore: '.$product->getCodeProducer().' --- Codice fornitore: '.$product->getCodeSupplier();
  24.         }
  25.         return $html;
  26.     }
  27.     /**
  28.      * @ORM\Column(name="id", type="bigint")
  29.      * @ORM\Id
  30.      * @ORM\GeneratedValue(strategy="AUTO")
  31.      */
  32.     protected $id;
  33.     
  34.     /**
  35.      * @ORM\Column(name="code", type="string", length=191)
  36.      */
  37.     protected $code;
  38.     // OneToMany
  39.         /**
  40.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Product", mappedBy="termid")
  41.          */
  42.         private $products;
  43.         /**
  44.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="termid")
  45.          */
  46.         private $tickets;
  47.     //
  48.     // ManyToOne
  49.         /**
  50.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Client", inversedBy="termids")
  51.          * @ORM\JoinColumn(name="client_id", referencedColumnName="id")
  52.          */
  53.         private $client;
  54.     //
  55.     public function __construct()
  56.     {
  57.         $this->products = new ArrayCollection();
  58.         $this->tickets = new ArrayCollection();
  59.     }
  60.     public function getId(): ?string
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getCode(): ?string
  65.     {
  66.         return $this->code;
  67.     }
  68.     public function setCode(string $code): self
  69.     {
  70.         $this->code $code;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, Product>
  75.      */
  76.     public function getProducts(): Collection
  77.     {
  78.         return $this->products;
  79.     }
  80.     public function addProduct(Product $product): self
  81.     {
  82.         if (!$this->products->contains($product)) {
  83.             $this->products->add($product);
  84.             $product->setTermid($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeProduct(Product $product): self
  89.     {
  90.         if ($this->products->removeElement($product)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($product->getTermid() === $this) {
  93.                 $product->setTermid(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     public function getClient(): ?Client
  99.     {
  100.         return $this->client;
  101.     }
  102.     public function setClient(?Client $client): self
  103.     {
  104.         $this->client $client;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Ticket>
  109.      */
  110.     public function getTickets(): Collection
  111.     {
  112.         return $this->tickets;
  113.     }
  114.     public function addTicket(Ticket $ticket): self
  115.     {
  116.         if (!$this->tickets->contains($ticket)) {
  117.             $this->tickets->add($ticket);
  118.             $ticket->setTermid($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeTicket(Ticket $ticket): self
  123.     {
  124.         if ($this->tickets->removeElement($ticket)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($ticket->getTermid() === $this) {
  127.                 $ticket->setTermid(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132. }