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.         public function getId(): ?string
  60.         {
  61.             return $this->id;
  62.         }
  63.         public function getSlug(): ?string
  64.         {
  65.             return $this->slug;
  66.         }
  67.         public function setSlug(string $slug): static
  68.         {
  69.             $this->slug $slug;
  70.             return $this;
  71.         }
  72.         public function getName(): ?string
  73.         {
  74.             return $this->name;
  75.         }
  76.         public function setName(string $name): static
  77.         {
  78.             $this->name $name;
  79.             return $this;
  80.         }
  81.         public function isUav(): ?bool
  82.         {
  83.             return $this->uav;
  84.         }
  85.         public function setUav(bool $uav): static
  86.         {
  87.             $this->uav $uav;
  88.             return $this;
  89.         }
  90.         public function getSupplier(): ?Supplier
  91.         {
  92.             return $this->supplier;
  93.         }
  94.         public function setSupplier(?Supplier $supplier): static
  95.         {
  96.             $this->supplier $supplier;
  97.             return $this;
  98.         }
  99.         /**
  100.          * @return Collection<int, SupplierOperationAlgorithm>
  101.          */
  102.         public function getAlgorithms(): Collection
  103.         {
  104.             return $this->algorithms;
  105.         }
  106.         public function addAlgorithm(SupplierOperationAlgorithm $algorithm): static
  107.         {
  108.             if (!$this->algorithms->contains($algorithm)) {
  109.                 $this->algorithms->add($algorithm);
  110.                 $algorithm->setOperation($this);
  111.             }
  112.             return $this;
  113.         }
  114.         public function removeAlgorithm(SupplierOperationAlgorithm $algorithm): static
  115.         {
  116.             if ($this->algorithms->removeElement($algorithm)) {
  117.                 // set the owning side to null (unless already changed)
  118.                 if ($algorithm->getOperation() === $this) {
  119.                     $algorithm->setOperation(null);
  120.                 }
  121.             }
  122.             return $this;
  123.         }
  124. }