<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'patch')]
#[ORM\Index(name: 'ix_uuid', columns: ['uuid'])]
#[ORM\Entity(repositoryClass: 'App\Entity\Repository\PatchRepository')]
class Patch
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'string', nullable: true)]
private $name;
#[ORM\Column(type: 'json', nullable: true)]
private $microclimate;
#[ORM\Column(type: 'json', nullable: true)]
private $location;
#[ORM\Column(type: 'integer', nullable: true)]
private $width;
#[ORM\Column(type: 'integer', nullable: true)]
private $length;
#[ORM\Column(type: 'integer', nullable: true)]
private $amount_rows;
#[ORM\Column(type: 'integer', nullable: true)]
private $amount_cols;
#[ORM\Column(type: 'integer', nullable: true)]
private $rasterSize;
#[ORM\Column(type: 'boolean', nullable: true)]
private $initialized;
#[ORM\Column(type: 'json', nullable: true)]
private $settings;
/**
*
*/
private $rows;
/**
*
*/
private $cols;
#[ORM\Column(type: 'string', nullable: true)]
private $shape;
#[ORM\Column(type: 'datetime', nullable: false)]
private $date_created;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_updated;
#[ORM\Column(type: 'integer', nullable: true)]
private $position_x;
#[ORM\Column(type: 'integer', nullable: true)]
private $position_y;
#[ORM\OneToMany(targetEntity: 'App\Entity\Patch', mappedBy: 'parentPatch')]
private $childPatch;
#[ORM\OneToMany(targetEntity: 'App\Entity\Patchfield', mappedBy: 'patch')]
private $patchfield;
/**
*
*/
private $patchCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\PatchfieldGroup', mappedBy: 'patch')]
private $patchfieldGroup;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'patch')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)]
private $user;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Patch', inversedBy: 'childPatch')]
#[ORM\JoinColumn(name: 'patch_id', referencedColumnName: 'id')]
private $parentPatch;
#[ORM\OneToMany(targetEntity: Plant::class, mappedBy: 'patch')]
private $plants;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isNewPlan;
#[ORM\Column(type: 'guid', nullable: true)]
private $uuid;
#[ORM\Column(type: 'json', nullable: true)]
private $data = [];
#[ORM\ManyToOne(targetEntity: Garden::class, inversedBy: 'patches')]
private $garden;
public function __construct()
{
$this->patchCrop = new ArrayCollection();
$this->patchfieldGroup = new ArrayCollection();
$this->patchfield = new ArrayCollection();
$this->childPatch = new ArrayCollection();
$this->plants = new ArrayCollection();
$this->date_created = new \DateTime();
}
public function __clone() {
$this->id = null;
$this->patchCrop = new ArrayCollection();
$this->patchfieldGroup = new ArrayCollection();
$this->patchfield = new ArrayCollection();
$this->childPatch = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
if( empty($this->name) && isset($this->data['name']) ) {
return $this->data['name'];
}
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getMicroclimate()
{
return $this->microclimate;
}
public function setMicroclimate($microclimate): self
{
$this->microclimate = $microclimate;
return $this;
}
public function getWidth(): ?int
{
return $this->width;
}
public function setWidth(?int $width): self
{
$this->width = $width;
return $this;
}
public function getLength(): ?int
{
return $this->length;
}
public function setLength(?int $length): self
{
$this->length = $length;
return $this;
}
public function getShape(): ?string
{
return $this->shape;
}
public function setShape(?string $shape): self
{
$this->shape = $shape;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
/**
* @return Collection|Patchfield[]
*/
public function getPatchCrop(): Collection
{
return $this->patchCrop;
}
public function addPatchCrop(Patchfield $patchCrop): self
{
if (!$this->patchCrop->contains($patchCrop)) {
$this->patchCrop[] = $patchCrop;
$patchCrop->setPatch($this);
}
return $this;
}
public function removePatchCrop(Patchfield $patchCrop): self
{
if ($this->patchCrop->contains($patchCrop)) {
$this->patchCrop->removeElement($patchCrop);
// set the owning side to null (unless already changed)
if ($patchCrop->getPatch() === $this) {
$patchCrop->setPatch(null);
}
}
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection|PatchfieldGroup[]
*/
public function getPatchfieldGroup(): Collection
{
return $this->patchfieldGroup;
}
public function addPatchfieldGroup(PatchfieldGroup $patchfieldGroup): self
{
if (!$this->patchfieldGroup->contains($patchfieldGroup)) {
$this->patchfieldGroup[] = $patchfieldGroup;
$patchfieldGroup->setPatch($this);
}
return $this;
}
public function removePatchfieldGroup(PatchfieldGroup $patchfieldGroup): self
{
if ($this->patchfieldGroup->contains($patchfieldGroup)) {
$this->patchfieldGroup->removeElement($patchfieldGroup);
// set the owning side to null (unless already changed)
if ($patchfieldGroup->getPatch() === $this) {
$patchfieldGroup->setPatch(null);
}
}
return $this;
}
public function getAmountRows(): ?int
{
return $this->amount_rows;
}
public function setAmountRows(?int $amount_rows): self
{
$this->amount_rows = $amount_rows;
return $this;
}
public function getAmountCols(): ?int
{
return $this->amount_cols;
}
public function setAmountCols(?int $amount_cols): self
{
$this->amount_cols = $amount_cols;
return $this;
}
/**
* @return Collection|Patchfield[]
*/
public function getPatchfield(): Collection
{
return $this->patchfield;
}
public function addPatchfield(Patchfield $patchfield): self
{
if (!$this->patchfield->contains($patchfield)) {
$this->patchfield[] = $patchfield;
$patchfield->setPatch($this);
}
return $this;
}
public function removePatchfield(Patchfield $patchfield): self
{
if ($this->patchfield->contains($patchfield)) {
$this->patchfield->removeElement($patchfield);
// set the owning side to null (unless already changed)
if ($patchfield->getPatch() === $this) {
$patchfield->setPatch(null);
}
}
return $this;
}
public function getDateUpdated(): ?\DateTimeInterface
{
return $this->date_updated;
}
public function setDateUpdated(?\DateTimeInterface $date_updated): self
{
$this->date_updated = $date_updated;
return $this;
}
public function getInitialized(): ?bool
{
return $this->initialized;
}
public function setInitialized(?bool $initialized): self
{
$this->initialized = $initialized;
return $this;
}
public function getLocation()
{
return $this->location;
}
public function setLocation($location): self
{
$this->location = $location;
return $this;
}
public function getPositionX(): ?int
{
return $this->position_x;
}
public function setPositionX(?int $position_x): self
{
$this->position_x = $position_x;
return $this;
}
public function getPositionY(): ?int
{
return $this->position_y;
}
public function setPositionY(?int $position_y): self
{
$this->position_y = $position_y;
return $this;
}
/**
* @return Collection|Patch[]
*/
public function getChildPatch(): Collection
{
return $this->childPatch;
}
public function addChildPatch(Patch $childPatch): self
{
if (!$this->childPatch->contains($childPatch)) {
$this->childPatch[] = $childPatch;
$childPatch->setParentPatch($this);
}
return $this;
}
public function removeChildPatch(Patch $childPatch): self
{
if ($this->childPatch->contains($childPatch)) {
$this->childPatch->removeElement($childPatch);
// set the owning side to null (unless already changed)
if ($childPatch->getParentPatch() === $this) {
$childPatch->setParentPatch(null);
}
}
return $this;
}
public function getParentPatch(): ?self
{
return $this->parentPatch;
}
public function setParentPatch(?self $parentPatch): self
{
$this->parentPatch = $parentPatch;
return $this;
}
public function getRasterSize(): ?int
{
return $this->rasterSize;
}
public function setRasterSize(?int $rasterSize): self
{
$this->rasterSize = $rasterSize;
return $this;
}
public function getSettings()
{
return $this->settings;
}
public function setSettings($settings): self
{
$this->settings = $settings;
return $this;
}
/**
* @return Collection|Plant[]
*/
public function getPlants(): Collection
{
return $this->plants;
}
public function addPlant(Plant $plant): self
{
if (!$this->plants->contains($plant)) {
$this->plants[] = $plant;
$plant->setPatch($this);
}
return $this;
}
public function removePlant(Plant $plant): self
{
if ($this->plants->removeElement($plant)) {
// set the owning side to null (unless already changed)
if ($plant->getPatch() === $this) {
$plant->setPatch(null);
}
}
return $this;
}
public function getIsNewPlan(): ?bool
{
return $this->isNewPlan;
}
public function setIsNewPlan(?bool $isNewPlan): self
{
$this->isNewPlan = $isNewPlan;
return $this;
}
public function getUuid(): ?string
{
return $this->uuid;
}
public function setUuid(?string $uuid): self
{
$this->uuid = $uuid;
return $this;
}
public function getData(): ?array
{
return $this->data;
}
public function setData(?array $data): self
{
$this->data = $data;
return $this;
}
public function getGarden(): ?Garden
{
return $this->garden;
}
public function setGarden(?Garden $garden): self
{
$this->garden = $garden;
return $this;
}
}