src/Entity/Plantfamily.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Translation\AutoTranslatableTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. #[ORM\Table(name'plantfamily')]
  9. #[ORM\Entity(repositoryClass'App\Entity\Repository\PlantfamilyRepository')]
  10. class Plantfamily implements TranslatableInterface
  11. {
  12.     use AutoTranslatableTrait;
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'integer')]
  15.     #[ORM\GeneratedValue(strategy'AUTO')]
  16.     private $id;
  17.     #[ORM\Column(type'string'uniquetruenullablefalse)]
  18.     private $name;
  19.     #[ORM\Column(type'datetime'nullablefalse)]
  20.     private $date_created;
  21.     #[ORM\OneToMany(targetEntity'App\Entity\Crop'mappedBy'plantfamily')]
  22.     private $crop;
  23.     #[ORM\Column(type'json'nullabletrue)]
  24.     private $settings = [];
  25.     #[ORM\Column(type'text'nullabletrue)]
  26.     private $description;
  27.     #[ORM\Column(nullabletrue)]
  28.     private ?float $cultivation_break null;
  29.     #[ORM\Column(length50nullabletrue)]
  30.     private ?string $nutrient_demand null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $latin_name null;
  33.     public function __construct()
  34.     {
  35.         $this->crop = new ArrayCollection();
  36.         $this->date_created = new \DateTime();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(bool $skipTranslation false): ?string
  43.     {
  44.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  45.             return $this->name;
  46.         }
  47.         $translated $this->translate()->getName();
  48.         return !empty($translated) ? $translated $this->name;
  49.     }
  50.     public function setName(string $name): self
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     public function getDateCreated(): ?\DateTimeInterface
  56.     {
  57.         return $this->date_created;
  58.     }
  59.     public function setDateCreated(\DateTimeInterface $date_created): self
  60.     {
  61.         $this->date_created $date_created;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection|Crop[]
  66.      */
  67.     public function getCrop(): Collection
  68.     {
  69.         return $this->crop;
  70.     }
  71.     public function addCrop(Crop $crop): self
  72.     {
  73.         if (!$this->crop->contains($crop)) {
  74.             $this->crop[] = $crop;
  75.             $crop->setPlantfamily($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeCrop(Crop $crop): self
  80.     {
  81.         if ($this->crop->removeElement($crop)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($crop->getPlantfamily() === $this) {
  84.                 $crop->setPlantfamily(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89.     public function getSettings(): ?array
  90.     {
  91.         return $this->settings;
  92.     }
  93.     public function setSettings(?array $settings): self
  94.     {
  95.         $this->settings $settings;
  96.         return $this;
  97.     }
  98.     public function getDescription(bool $skipTranslation false): ?string
  99.     {
  100.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  101.             return $this->description;
  102.         }
  103.         $translated $this->translate()->getDescription();
  104.         return !empty($translated) ? $translated $this->description;
  105.     }
  106.     public function setDescription(?string $description): self
  107.     {
  108.         $this->description $description;
  109.         return $this;
  110.     }
  111.     public function getCultivationBreak(): ?float
  112.     {
  113.         return $this->cultivation_break;
  114.     }
  115.     public function setCultivationBreak(?float $cultivation_break): static
  116.     {
  117.         $this->cultivation_break $cultivation_break;
  118.         return $this;
  119.     }
  120.     public function getNutrientDemand(): ?string
  121.     {
  122.         return $this->nutrient_demand;
  123.     }
  124.     public function setNutrientDemand(?string $nutrient_demand): static
  125.     {
  126.         $this->nutrient_demand $nutrient_demand;
  127.         return $this;
  128.     }
  129.     public function getLatinName(): ?string
  130.     {
  131.         return $this->latin_name;
  132.     }
  133.     public function setLatinName(?string $latin_name): static
  134.     {
  135.         $this->latin_name $latin_name;
  136.         return $this;
  137.     }
  138. }