src/Entity/Variable.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\VariableRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassVariableRepository::class)]
  10. #[ApiResource]
  11. class Variable
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length100)]
  18.     private ?string $name null;
  19.     #[ORM\Column(length20)]
  20.     private ?string $abreviation null;
  21.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  22.     private ?string $varFunction null;
  23.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  24.     private ?string $varDefinition null;
  25.     #[ORM\ManyToOne(inversedBy'variables')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private ?Units $units null;
  28.     #[ORM\OneToMany(mappedBy'productVariable'targetEntityProduct::class, orphanRemovaltrue)]
  29.     private Collection $products;
  30.     #[ORM\OneToMany(mappedBy'variable'targetEntityProviderDatabaseVariable::class, orphanRemovaltrue)]
  31.     private Collection $providerDatabaseVariables;
  32.     #[ORM\OneToMany(mappedBy'variable'targetEntityObservation::class, orphanRemovaltrue)]
  33.     private Collection $observations;
  34.     public function __construct()
  35.     {
  36.         $this->products = new ArrayCollection();
  37.         $this->providerDatabaseVariables = new ArrayCollection();
  38.         $this->observations = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): self
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function getAbreviation(): ?string
  54.     {
  55.         return $this->abreviation;
  56.     }
  57.     public function setAbreviation(string $abreviation): self
  58.     {
  59.         $this->abreviation $abreviation;
  60.         return $this;
  61.     }
  62.     public function getVarFunction(): ?string
  63.     {
  64.         return $this->varFunction;
  65.     }
  66.     public function setVarFunction(?string $varFunction): self
  67.     {
  68.         $this->varFunction $varFunction;
  69.         return $this;
  70.     }
  71.     public function getVarDefinition(): ?string
  72.     {
  73.         return $this->varDefinition;
  74.     }
  75.     public function setVarDefinition(?string $varDefinition): self
  76.     {
  77.         $this->varDefinition $varDefinition;
  78.         return $this;
  79.     }
  80.     public function getUnits(): ?Units
  81.     {
  82.         return $this->units;
  83.     }
  84.     public function setUnits(?Units $units): self
  85.     {
  86.         $this->units $units;
  87.         return $this;
  88.     }
  89.     /**
  90.      * @return Collection<int, Product>
  91.      */
  92.     public function getProducts(): Collection
  93.     {
  94.         return $this->products;
  95.     }
  96.     public function addProduct(Product $product): self
  97.     {
  98.         if (!$this->products->contains($product)) {
  99.             $this->products->add($product);
  100.             $product->setProductVariable($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function removeProduct(Product $product): self
  105.     {
  106.         if ($this->products->removeElement($product)) {
  107.             // set the owning side to null (unless already changed)
  108.             if ($product->getProductVariable() === $this) {
  109.                 $product->setProductVariable(null);
  110.             }
  111.         }
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, ProviderDatabaseVariable>
  116.      */
  117.     public function getProviderDatabaseVariables(): Collection
  118.     {
  119.         return $this->providerDatabaseVariables;
  120.     }
  121.     public function addProviderDatabaseVariable(ProviderDatabaseVariable $providerDatabaseVariable): self
  122.     {
  123.         if (!$this->providerDatabaseVariables->contains($providerDatabaseVariable)) {
  124.             $this->providerDatabaseVariables->add($providerDatabaseVariable);
  125.             $providerDatabaseVariable->setVariable($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeProviderDatabaseVariable(ProviderDatabaseVariable $providerDatabaseVariable): self
  130.     {
  131.         if ($this->providerDatabaseVariables->removeElement($providerDatabaseVariable)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($providerDatabaseVariable->getVariable() === $this) {
  134.                 $providerDatabaseVariable->setVariable(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection<int, Observation>
  141.      */
  142.     public function getObservations(): Collection
  143.     {
  144.         return $this->observations;
  145.     }
  146.     public function addObservation(Observation $observation): self
  147.     {
  148.         if (!$this->observations->contains($observation)) {
  149.             $this->observations->add($observation);
  150.             $observation->setVariable($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeObservation(Observation $observation): self
  155.     {
  156.         if ($this->observations->removeElement($observation)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($observation->getVariable() === $this) {
  159.                 $observation->setVariable(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164. }