<?php
namespace App\Entity;
use App\Constant\RecommendationStatusConstant;
use App\Entity\Report\Report;
use App\Entity\Report\ReportValue;
use App\Repository\RecommendationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=RecommendationRepository::class)
*/
class Recommendation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $status;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=Field::class, inversedBy="recommendations")
*/
private $field;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $problem;
/**
* @ORM\Column(type="text")
*/
private $recommendationTitle;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\ManyToOne(targetEntity=Client::class)
*/
private $subdivision;
/**
* @ORM\ManyToOne(targetEntity=Culture::class)
*/
private $culture;
/**
* @ORM\ManyToOne(targetEntity=Season::class)
*/
private $season;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $hash;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $owner;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $viewer;
/**
* @ORM\Column(type="boolean")
*/
private $removed;
/**
* @ORM\ManyToOne(targetEntity=Report::class, inversedBy="recommendations",cascade={"persist","remove"})
*/
private $report;
/**
* @ORM\ManyToOne(targetEntity=ReportValue::class, inversedBy="recommendations")
*/
private $reportValue;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $completedAt;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $custom;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $parameterId;
/**
* @ORM\OneToMany(targetEntity=Image::class, mappedBy="recommendation",cascade={"persist","remove"})
*/
private $images;
public function __construct()
{
if(is_null($this->id)){
$this->createdAt = new \DateTime();
$this->removed = false;
$this->custom = false;
$this->status = RecommendationStatusConstant::NEW;
}
$this->updatedAt = new \DateTime();
$this->setHash();
$this->images = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getField(): ?Field
{
return $this->field;
}
public function setField(?Field $field): self
{
$this->field = $field;
return $this;
}
public function getProblem(): ?string
{
return $this->problem;
}
public function setProblem(?string $problem): self
{
$this->problem = $problem;
return $this;
}
public function getRecommendationTitle(): ?string
{
return $this->recommendationTitle;
}
public function setRecommendationTitle(string $recommendationTitle): self
{
$this->recommendationTitle = $recommendationTitle;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getSubdivision(): ?Client
{
return $this->subdivision;
}
public function setSubdivision(?Client $subdivision): self
{
$this->subdivision = $subdivision;
return $this;
}
public function getCulture(): ?Culture
{
return $this->culture;
}
public function setCulture(?Culture $culture): self
{
$this->culture = $culture;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): self
{
$this->season = $season;
return $this;
}
public function getHash(): ?string
{
return $this->hash;
}
public function setHash(): self
{
$this->hash = md5(date('YmdHis') . microtime(true) . rand(0, 999999));
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
public function getViewer(): ?User
{
return $this->viewer;
}
public function setViewer(?User $viewer): self
{
$this->viewer = $viewer;
return $this;
}
public function isRemoved(): ?bool
{
return $this->removed;
}
public function setRemoved(bool $removed): self
{
$this->removed = $removed;
return $this;
}
public function getReport(): ?Report
{
return $this->report;
}
public function setReport(?Report $report): self
{
$this->report = $report;
return $this;
}
public function getReportValue(): ?ReportValue
{
return $this->reportValue;
}
public function setReportValue(?ReportValue $reportValue): self
{
$this->reportValue = $reportValue;
return $this;
}
public function getCompletedAt(): ?\DateTimeInterface
{
return $this->completedAt;
}
public function setCompletedAt(?\DateTimeInterface $completedAt): self
{
$this->completedAt = $completedAt;
return $this;
}
public function isCustom(): ?bool
{
return $this->custom;
}
public function setCustom(?bool $custom): self
{
$this->custom = $custom;
return $this;
}
public function getParameterId(): ?int
{
return $this->parameterId;
}
public function setParameterId(?int $parameterId): self
{
$this->parameterId = $parameterId;
return $this;
}
/**
* @return Collection<int, Image>
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(Image $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
$image->setRecommendation($this);
}
return $this;
}
public function removeImage(Image $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getRecommendation() === $this) {
$image->setRecommendation(null);
}
}
return $this;
}
}