src/Entity/Master/SupplierOperation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Master;
  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_m_supplier_operation")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Master\SupplierOperationRepository")
  10.  */
  11. class SupplierOperation
  12. {
  13.     public function canDelete(){
  14.         if(sizeof($this->getSupplier()->getCompanies()) > 0)
  15.             return false;
  16.         return true;
  17.     }
  18.     
  19.     public function __toString(){
  20.         return $this->name;
  21.     }
  22.     /**
  23.      * @ORM\Column(name="id", type="bigint")
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     protected $id;
  28.     
  29.     /**
  30.      * @ORM\Column(name="slug", type="string", length=191, unique=true)
  31.      */
  32.     protected $slug;
  33.         
  34.     /**
  35.      * @ORM\Column(name="name", type="string", length=191)
  36.      */
  37.     protected $name;
  38.     /**
  39.      * @ORM\Column(name="uav", type="boolean")
  40.      */
  41.     protected $uav false;
  42.     // ManyToOne
  43.         /**
  44.          * @ORM\ManyToOne(targetEntity="App\Entity\Master\Supplier", inversedBy="operations")
  45.          * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id")
  46.          */
  47.         private $supplier;
  48.     //
  49.     
  50.     // OneToMany
  51.         /**
  52.          * @ORM\OneToMany(targetEntity="App\Entity\Master\SupplierOperationAlgorithm", mappedBy="operation")
  53.          */
  54.         private $algorithms;
  55.         public function __construct()
  56.         {
  57.             $this->algorithms = new ArrayCollection();
  58.         }
  59.     //
  60.     public function getId(): ?string
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getSlug(): ?string
  65.     {
  66.         return $this->slug;
  67.     }
  68.     public function setSlug(string $slug): self
  69.     {
  70.         $this->slug $slug;
  71.         return $this;
  72.     }
  73.     public function getName(): ?string
  74.     {
  75.         return $this->name;
  76.     }
  77.     public function setName(string $name): self
  78.     {
  79.         $this->name $name;
  80.         return $this;
  81.     }
  82.     public function isUav(): ?bool
  83.     {
  84.         return $this->uav;
  85.     }
  86.     public function setUav(bool $uav): self
  87.     {
  88.         $this->uav $uav;
  89.         return $this;
  90.     }
  91.     public function getSupplier(): ?Supplier
  92.     {
  93.         return $this->supplier;
  94.     }
  95.     public function setSupplier(?Supplier $supplier): self
  96.     {
  97.         $this->supplier $supplier;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, SupplierOperationAlgorithm>
  102.      */
  103.     public function getAlgorithms(): Collection
  104.     {
  105.         return $this->algorithms;
  106.     }
  107.     public function addAlgorithm(SupplierOperationAlgorithm $algorithm): self
  108.     {
  109.         if (!$this->algorithms->contains($algorithm)) {
  110.             $this->algorithms->add($algorithm);
  111.             $algorithm->setOperation($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeAlgorithm(SupplierOperationAlgorithm $algorithm): self
  116.     {
  117.         if ($this->algorithms->removeElement($algorithm)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($algorithm->getOperation() === $this) {
  120.                 $algorithm->setOperation(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125. }