<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Uid\Uuid;
/**
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\FarmRepository")
* @ORM\Table(indexes={
* @ORM\Index(name="name",columns={"name"}),
* @ORM\Index(name="deleted",columns={"deleted"}),
* @ORM\Index(name="created",columns={"created"}),
* @ORM\Index(name="createdAt",columns={"created_at"}),
* @ORM\Index(name="updatedAt",columns={"updated_at"}),
* @ORM\Index(name="deletedAt",columns={"deleted_at"}),
* })
* @ORM\HasLifecycleCallbacks
*/
class Farm
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Groups({"read", "write", "api_get"})
*/
private $id;
/**
* @ORM\Column(type="string", length=36, nullable=false)
*/
private $uuid;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"read", "write"})
*/
private $cottage;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"read", "write"})
*/
private $raise;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cuartel;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $feedlot;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $wintering;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $mix;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"api_get"})
*/
private $name;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $other;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $picture;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $created;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $tambo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tenure;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"api_get"})
*/
private $renspa;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cuig;
/**
* @ORM\ManyToOne(targetEntity="Address", cascade={"persist"})
* @ORM\JoinColumn(name="address_id", referencedColumnName="id")
*/
private $address;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $hectares;
/**
* Many Farms have one producer.
* @ORM\ManyToOne(targetEntity="Producer", inversedBy="farms", cascade={"persist"})
* @ORM\JoinColumn(name="producer_id", referencedColumnName="id")
*/
private $producer;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $timeStamp;
/**
* @var bool
* @ORM\Column(name="deleted", type="boolean", nullable=true)
* @Groups({"api_get"})
*/
private $deleted = false;
/**
* @ORM\OneToMany(targetEntity="Lot", mappedBy="farm")
*/
private $lots;
/**
* @var bool
* @ORM\Column(name="demo", type="boolean", nullable=true)
* @Groups({"api_get"})
*/
private $demo = false;
/**
* Many Farms have One Organization
* @ORM\ManyToOne(targetEntity="Organization")
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id")
*/
private $organization;
/**
* One Farm has many locations.
* @ORM\OneToMany(targetEntity="Location", mappedBy="farm")
*/
private $locations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $activity;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @ORM\OneToMany(targetEntity=FarmProducer::class, mappedBy="farm", orphanRemoval=false)
*/
private $farmProducers;
/* desnormalizado de farmProducers */
private $producers;
/** @ORM\PreUpdate */
public function PreUpdate()
{
$this->setUpdatedAt( new \DateTime() );
}
/** @ORM\PrePersist */
public function PrePersist()
{
$this->setCreatedAt( new \DateTime() );
$this->setUpdatedAt( new \DateTime() );
}
public function __construct()
{
$this->created = new \DateTime();
$this->lots = new ArrayCollection();
$this->locations = new ArrayCollection();
$this->farmProducers = new ArrayCollection();
$this->uuid = Uuid::v6();
}
public function getUuid()
{
return $this->uuid;
}
public function setUuid($uuid): self
{
$this->uuid = $uuid;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getCottage(): ?bool
{
return $this->cottage;
}
public function setCottage(bool $cottage): self
{
$this->cottage = $cottage;
return $this;
}
public function getRaise(): ?bool
{
return $this->raise;
}
public function setRaise(bool $raise): self
{
$this->raise = $raise;
return $this;
}
public function getCuartel(): ?string
{
return $this->cuartel;
}
public function setCuartel(?string $cuartel): self
{
$this->cuartel = $cuartel;
return $this;
}
public function getFeedlot(): ?bool
{
return $this->feedlot;
}
public function setFeedlot(bool $feedlot): self
{
$this->feedlot = $feedlot;
return $this;
}
public function getWintering(): ?bool
{
return $this->wintering;
}
public function setWintering(?bool $wintering): self
{
$this->wintering = $wintering;
return $this;
}
public function getMix(): ?bool
{
return $this->mix;
}
public function setMix(?bool $mix): self
{
$this->mix = $mix;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getOther(): ?bool
{
return $this->other;
}
public function setOther(?bool $other): self
{
$this->other = $other;
return $this;
}
public function getPicture(): ?string
{
return $this->picture;
}
public function setPicture(?string $picture): self
{
$this->picture = $picture;
return $this;
}
public function getTambo(): ?bool
{
return $this->tambo;
}
public function setTambo(?bool $tambo): self
{
$this->tambo = $tambo;
return $this;
}
public function getTenure(): ?string
{
return $this->tenure;
}
public function setTenure(?string $tenure): self
{
$this->tenure = $tenure;
return $this;
}
/**
* @return mixed
*/
public function getAddress()
{
return $this->address;
}
/**
* @param mixed $address
*/
public function setAddress($address): void
{
$this->address = $address;
}
public function getHectares(): ?string
{
return $this->hectares;
}
public function setHectares(?string $hectares): self
{
$this->hectares = $hectares;
return $this;
}
/**
* @return mixed
*/
public function getCreated()
{
return $this->created;
}
/**
* @param mixed $created
*/
public function setCreated($created)
{
$this->created = $created;
}
/**
* @return mixed
*/
public function getProducer()
{
return $this->producer;
}
/**
* @param mixed $producer
*/
public function setProducer($producer): void
{
$this->producer = $producer;
}
/**
* @return mixed
*/
public function getTimeStamp()
{
return $this->timeStamp;
}
/**
* @param mixed $timeStamp
*/
public function setTimeStamp($timeStamp): void
{
$this->timeStamp = $timeStamp;
}
/**
* @return mixed
*/
public function getRenspa()
{
return $this->renspa;
}
/**
* @param mixed $renspa
*/
public function setRenspa($renspa): void
{
$this->renspa = $renspa;
}
/**
* @return mixed
*/
public function getCuig()
{
return $this->cuig;
}
/**
* @param mixed $cuig
*/
public function setCuig($cuig): void
{
$this->cuig = strtoupper($cuig);
}
/**
* @return bool
*/
public function isDeleted(): bool
{
return $this->deleted;
}
public function setDeleted(bool $deleted): self
{
$this->deleted = $deleted;
$this->deletedAt = ( $deleted ) ? new \DateTime() : null;
return $this;
}
public function __toString()
{
return $this->name ?? ' - ';
}
public function getDeleted(): ?bool
{
return $this->deleted;
}
public function getDemo(): ?bool
{
return $this->demo;
}
public function setDemo(?bool $demo): self
{
$this->demo = $demo;
return $this;
}
/**
* @return Collection|Lot[]
*/
public function getLots(): Collection
{
return $this->lots;
}
public function addLot(Lot $lot): self
{
if (!$this->lots->contains($lot)) {
$this->lots[] = $lot;
$lot->setFarm($this);
}
return $this;
}
public function removeLot(Lot $lot): self
{
if ($this->lots->removeElement($lot)) {
// set the owning side to null (unless already changed)
if ($lot->getFarm() === $this) {
$lot->setFarm(null);
}
}
return $this;
}
public function getOrganization(): ?Organization
{
return $this->organization;
}
public function setOrganization(?Organization $organization): self
{
$this->organization = $organization;
return $this;
}
/**
* @return Collection|Location[]
*/
public function getLocations(): Collection
{
return $this->locations;
}
public function addLocation(Location $location): self
{
if (!$this->locations->contains($location)) {
$this->locations[] = $location;
$location->setFarm($this);
}
return $this;
}
public function removeLocation(Location $location): self
{
if ($this->locations->removeElement($location)) {
// set the owning side to null (unless already changed)
if ($location->getFarm() === $this) {
$location->setFarm(null);
}
}
return $this;
}
public function isCottage(): ?bool
{
return $this->cottage;
}
public function isRaise(): ?bool
{
return $this->raise;
}
public function isFeedlot(): ?bool
{
return $this->feedlot;
}
public function isWintering(): ?bool
{
return $this->wintering;
}
public function isMix(): ?bool
{
return $this->mix;
}
public function isOther(): ?bool
{
return $this->other;
}
public function isTambo(): ?bool
{
return $this->tambo;
}
public function isDemo(): ?bool
{
return $this->demo;
}
public function getActivity(): ?string
{
return $this->activity;
}
public function setActivity(?string $activity): self
{
$this->activity = $activity;
return $this;
}
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
public function setCreatedAt(\DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTime $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getDeletedAt(): ?\DateTime
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTime $deletedAt): self
{
$this->deletedAt = $deletedAt;
$this->deleted = (boolean) $deletedAt;
return $this;
}
/**
* @return Collection<int, FarmProducer>
*/
public function getFarmProducers(): Collection
{
return $this->farmProducers;
}
public function addFarmProducer(FarmProducer $farmProducer): self
{
if (!$this->farmProducers->contains($farmProducer)) {
$this->farmProducers[] = $farmProducer;
$farmProducer->setFarm($this);
}
return $this;
}
public function removeFarmProducer(FarmProducer $farmProducer): self
{
if ($this->farmProducers->removeElement($farmProducer)) {
// set the owning side to null (unless already changed)
if ($farmProducer->getFarm() === $this) {
$farmProducer->setDeletedAt( new \DateTime() );
}
}
return $this;
}
public function clearFarmProducers(): self
{
$this->farmProducers->clear();
return $this;
}
}