src/Entity/Garden.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GardenRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassGardenRepository::class)]
  8. #[ORM\Index(name'ix_public_hash'columns: ['public_hash'])]
  9. class Garden
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'json')]
  16.     private $gardenData = [];
  17.     #[ORM\Column(type'json')]
  18.     private $planData = [];
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private $imagePath;
  21.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'gardens')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private $user;
  24.     #[ORM\Column(type'datetime')]
  25.     private $createdAt;
  26.     #[ORM\Column(type'datetime')]
  27.     private $updatedAt;
  28.     #[ORM\OneToMany(targetEntityPatch::class, mappedBy'garden')]
  29.     private $patches;
  30.     #[ORM\Column(type'json'nullabletrue)]
  31.     private $additionalData = [];
  32.     #[ORM\Column(type'string'length100nullabletrue)]
  33.     private $hash;
  34.     #[ORM\Column(type'json'nullabletrue)]
  35.     private $deviceInformation = [];
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     private $name;
  38.     #[ORM\OneToMany(targetEntityTodo::class, mappedBy'garden')]
  39.     private $todos;
  40.     #[ORM\Column(nullabletrue)]
  41.     private ?array $warnings = [];
  42.     #[ORM\Column(length255nullabletrue)]
  43.     private ?string $public_hash null;
  44.     #[ORM\Column(length255nullabletrue)]
  45.     private ?string $dynamic_link null;
  46.     public function __construct()
  47.     {
  48.         $this->patches = new ArrayCollection();
  49.         $this->createdAt = new \DateTime();
  50.         $this->todos = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getGardenData(): ?array
  57.     {
  58.         return $this->gardenData;
  59.     }
  60.     public function setGardenData(array $gardenData): self
  61.     {
  62.         $this->gardenData $gardenData;
  63.         return $this;
  64.     }
  65.     public function getPlanData(): ?array
  66.     {
  67.         return $this->planData;
  68.     }
  69.     public function setPlanData(array $planData): self
  70.     {
  71.         $this->planData $planData;
  72.         return $this;
  73.     }
  74.     public function getImagePath(): ?string
  75.     {
  76.         return $this->imagePath;
  77.     }
  78.     public function setImagePath(?string $imagePath): self
  79.     {
  80.         $this->imagePath $imagePath;
  81.         return $this;
  82.     }
  83.     public function getUser(): ?User
  84.     {
  85.         return $this->user;
  86.     }
  87.     public function setUser(?User $user): self
  88.     {
  89.         $this->user $user;
  90.         return $this;
  91.     }
  92.     public function getCreatedAt(): ?\DateTimeInterface
  93.     {
  94.         return $this->createdAt;
  95.     }
  96.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  97.     {
  98.         $this->createdAt $createdAt;
  99.         return $this;
  100.     }
  101.     public function getUpdatedAt(): ?\DateTimeInterface
  102.     {
  103.         return $this->updatedAt;
  104.     }
  105.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  106.     {
  107.         $this->updatedAt $updatedAt;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return Collection|Patch[]
  112.      */
  113.     public function getPatches(): Collection
  114.     {
  115.         return $this->patches;
  116.     }
  117.     public function addPatch(Patch $patch): self
  118.     {
  119.         if (!$this->patches->contains($patch)) {
  120.             $this->patches[] = $patch;
  121.             $patch->setGarden($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function removePatch(Patch $patch): self
  126.     {
  127.         if ($this->patches->removeElement($patch)) {
  128.             // set the owning side to null (unless already changed)
  129.             if ($patch->getGarden() === $this) {
  130.                 $patch->setGarden(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135.     public function getAdditionalData(): ?array
  136.     {
  137.         return $this->additionalData;
  138.     }
  139.     public function setAdditionalData(?array $additionalData): self
  140.     {
  141.         $this->additionalData $additionalData;
  142.         return $this;
  143.     }
  144.     public function getHash(): ?string
  145.     {
  146.         return $this->hash;
  147.     }
  148.     public function setHash(?string $hash): self
  149.     {
  150.         $this->hash $hash;
  151.         return $this;
  152.     }
  153.     public function getDeviceInformation(): ?array
  154.     {
  155.         return $this->deviceInformation;
  156.     }
  157.     public function setDeviceInformation(?array $deviceInformation): self
  158.     {
  159.         $this->deviceInformation $deviceInformation;
  160.         return $this;
  161.     }
  162.     public function getOccupancy($year$season 'main'): float
  163.     {
  164.         return $this->gardenData['occupancy'][$year][$season] ?? 0;
  165.     }
  166.     public function getName(): ?string
  167.     {
  168.         return $this->name;
  169.     }
  170.     public function setName(?string $name): self
  171.     {
  172.         $this->name $name;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return Collection<int, Todo>
  177.      */
  178.     public function getTodos(): Collection
  179.     {
  180.         return $this->todos;
  181.     }
  182.     public function addTodo(Todo $todo): self
  183.     {
  184.         if (!$this->todos->contains($todo)) {
  185.             $this->todos[] = $todo;
  186.             $todo->setGarden($this);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeTodo(Todo $todo): self
  191.     {
  192.         if ($this->todos->removeElement($todo)) {
  193.             // set the owning side to null (unless already changed)
  194.             if ($todo->getGarden() === $this) {
  195.                 $todo->setGarden(null);
  196.             }
  197.         }
  198.         return $this;
  199.     }
  200.     public function getWarnings(): ?array
  201.     {
  202.         return $this->warnings;
  203.     }
  204.     public function setWarnings(?array $warnings): static
  205.     {
  206.         $this->warnings $warnings;
  207.         return $this;
  208.     }
  209.     public function getPublicHash(): ?string
  210.     {
  211.         return $this->public_hash;
  212.     }
  213.     public function setPublicHash(?string $public_hash): static
  214.     {
  215.         $this->public_hash $public_hash;
  216.         return $this;
  217.     }
  218.     public function getDynamicLink(): ?string
  219.     {
  220.         return $this->dynamic_link;
  221.     }
  222.     public function setDynamicLink(?string $dynamic_link): static
  223.     {
  224.         $this->dynamic_link $dynamic_link;
  225.         return $this;
  226.     }
  227. }