<?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_supplier_operation")
* @ORM\Entity(repositoryClass="App\Repository\Master\SupplierOperationRepository")
*/
class SupplierOperation
{
public function canDelete(){
if(sizeof($this->getSupplier()->getCompanies()) > 0)
return false;
return true;
}
public function __toString(){
return $this->name;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="slug", type="string", length=191, unique=true)
*/
protected $slug;
/**
* @ORM\Column(name="name", type="string", length=191)
*/
protected $name;
/**
* @ORM\Column(name="uav", type="boolean")
*/
protected $uav = false;
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Master\Supplier", inversedBy="operations")
* @ORM\JoinColumn(name="supplier_id", referencedColumnName="id")
*/
private $supplier;
//
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Master\SupplierOperationAlgorithm", mappedBy="operation")
*/
private $algorithms;
public function __construct()
{
$this->algorithms = 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 getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function isUav(): ?bool
{
return $this->uav;
}
public function setUav(bool $uav): self
{
$this->uav = $uav;
return $this;
}
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
public function setSupplier(?Supplier $supplier): self
{
$this->supplier = $supplier;
return $this;
}
/**
* @return Collection<int, SupplierOperationAlgorithm>
*/
public function getAlgorithms(): Collection
{
return $this->algorithms;
}
public function addAlgorithm(SupplierOperationAlgorithm $algorithm): self
{
if (!$this->algorithms->contains($algorithm)) {
$this->algorithms->add($algorithm);
$algorithm->setOperation($this);
}
return $this;
}
public function removeAlgorithm(SupplierOperationAlgorithm $algorithm): self
{
if ($this->algorithms->removeElement($algorithm)) {
// set the owning side to null (unless already changed)
if ($algorithm->getOperation() === $this) {
$algorithm->setOperation(null);
}
}
return $this;
}
}