<?php
namespace App\Entity\Master;
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_m_company_mailer")
* @ORM\Entity
*/
class CompanyMailer
{
function getDisplaySuppliers(){
$string = "";
$first = true;
foreach($this->suppliers as $sup){
if($first) $first = false; else $string.=", ";
$string.= $sup->getName();
}
return $string;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="nickname", type="string", length=191, nullable=true)
*/
protected $nickname;
/**
* @ORM\Column(name="user", type="string", length=191, nullable=true)
*/
protected $user;
/**
* @ORM\Column(name="password", type="string", length=191, nullable=true)
*/
protected $password;
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Master\Company", inversedBy="mailers")
* @ORM\JoinColumn(name="company_id", referencedColumnName="id")
*/
private $company;
//
// ManyToMany
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Master\Supplier", mappedBy="mailers")
*/
private $suppliers;
public function __construct()
{
$this->suppliers = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getNickname(): ?string
{
return $this->nickname;
}
public function setNickname(?string $nickname): static
{
$this->nickname = $nickname;
return $this;
}
public function getUser(): ?string
{
return $this->user;
}
public function setUser(?string $user): static
{
$this->user = $user;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(?string $password): static
{
$this->password = $password;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): static
{
$this->company = $company;
return $this;
}
/**
* @return Collection<int, Supplier>
*/
public function getSuppliers(): Collection
{
return $this->suppliers;
}
public function addSupplier(Supplier $supplier): static
{
if (!$this->suppliers->contains($supplier)) {
$this->suppliers->add($supplier);
$supplier->addMailer($this);
}
return $this;
}
public function removeSupplier(Supplier $supplier): static
{
if ($this->suppliers->removeElement($supplier)) {
$supplier->removeMailer($this);
}
return $this;
}
}