src/Entity/Recommendation.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constant\RecommendationStatusConstant;
  4. use App\Entity\Report\Report;
  5. use App\Entity\Report\ReportValue;
  6. use App\Repository\RecommendationRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity(repositoryClass=RecommendationRepository::class)
  12.  */
  13. class Recommendation
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255, nullable=true)
  23.      */
  24.     private $status;
  25.     /**
  26.      * @ORM\Column(type="datetime", nullable=true)
  27.      */
  28.     private $createdAt;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Field::class, inversedBy="recommendations")
  31.      */
  32.     private $field;
  33.     /**
  34.      * @ORM\Column(type="text", nullable=true)
  35.      */
  36.     private $problem;
  37.     /**
  38.      * @ORM\Column(type="text")
  39.      */
  40.     private $recommendationTitle;
  41.     /**
  42.      * @ORM\Column(type="datetime", nullable=true)
  43.      */
  44.     private $updatedAt;
  45.     /**
  46.      * @ORM\Column(type="text", nullable=true)
  47.      */
  48.     private $comment;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=Client::class)
  51.      */
  52.     private $subdivision;
  53.     /**
  54.      * @ORM\ManyToOne(targetEntity=Culture::class)
  55.      */
  56.     private $culture;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity=Season::class)
  59.      */
  60.     private $season;
  61.     /**
  62.      * @ORM\Column(type="string", length=255, nullable=true)
  63.      */
  64.     private $hash;
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity=User::class)
  67.      */
  68.     private $owner;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=User::class)
  71.      */
  72.     private $viewer;
  73.     /**
  74.      * @ORM\Column(type="boolean")
  75.      */
  76.     private $removed;
  77.     /**
  78.      * @ORM\ManyToOne(targetEntity=Report::class, inversedBy="recommendations",cascade={"persist","remove"})
  79.      */
  80.     private $report;
  81.     /**
  82.      * @ORM\ManyToOne(targetEntity=ReportValue::class, inversedBy="recommendations")
  83.      */
  84.     private $reportValue;
  85.     /**
  86.      * @ORM\Column(type="datetime", nullable=true)
  87.      */
  88.     private $completedAt;
  89.     /**
  90.      * @ORM\Column(type="boolean", nullable=true)
  91.      */
  92.     private $custom;
  93.     /**
  94.      * @ORM\Column(type="integer", nullable=true)
  95.      */
  96.     private $parameterId;
  97.     /**
  98.      * @ORM\OneToMany(targetEntity=Image::class, mappedBy="recommendation",cascade={"persist","remove"})
  99.      */
  100.     private $images;
  101.   public function __construct()
  102.   {
  103.     if(is_null($this->id)){
  104.       $this->createdAt = new \DateTime();
  105.         $this->removed false;
  106.         $this->custom false;
  107.       $this->status RecommendationStatusConstant::NEW;
  108.     }
  109.       $this->updatedAt = new \DateTime();
  110.     $this->setHash();
  111.     $this->images = new ArrayCollection();
  112.   }
  113.   public function getId(): ?int
  114.     {
  115.         return $this->id;
  116.     }
  117.     public function getText(): ?string
  118.     {
  119.         return $this->text;
  120.     }
  121.     public function setText(string $text): self
  122.     {
  123.         $this->text $text;
  124.         return $this;
  125.     }
  126.     public function getStatus(): ?string
  127.     {
  128.         return $this->status;
  129.     }
  130.     public function setStatus(?string $status): self
  131.     {
  132.         $this->status $status;
  133.         return $this;
  134.     }
  135.     public function getCreatedAt(): ?\DateTimeInterface
  136.     {
  137.         return $this->createdAt;
  138.     }
  139.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  140.     {
  141.         $this->createdAt $createdAt;
  142.         return $this;
  143.     }
  144.     public function getField(): ?Field
  145.     {
  146.         return $this->field;
  147.     }
  148.     public function setField(?Field $field): self
  149.     {
  150.         $this->field $field;
  151.         return $this;
  152.     }
  153.     public function getProblem(): ?string
  154.     {
  155.         return $this->problem;
  156.     }
  157.     public function setProblem(?string $problem): self
  158.     {
  159.         $this->problem $problem;
  160.         return $this;
  161.     }
  162.     public function getRecommendationTitle(): ?string
  163.     {
  164.         return $this->recommendationTitle;
  165.     }
  166.     public function setRecommendationTitle(string $recommendationTitle): self
  167.     {
  168.         $this->recommendationTitle $recommendationTitle;
  169.         return $this;
  170.     }
  171.     public function getUpdatedAt(): ?\DateTimeInterface
  172.     {
  173.         return $this->updatedAt;
  174.     }
  175.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  176.     {
  177.         $this->updatedAt $updatedAt;
  178.         return $this;
  179.     }
  180.     public function getComment(): ?string
  181.     {
  182.         return $this->comment;
  183.     }
  184.     public function setComment(?string $comment): self
  185.     {
  186.         $this->comment $comment;
  187.         return $this;
  188.     }
  189.     public function getSubdivision(): ?Client
  190.     {
  191.         return $this->subdivision;
  192.     }
  193.     public function setSubdivision(?Client $subdivision): self
  194.     {
  195.         $this->subdivision $subdivision;
  196.         return $this;
  197.     }
  198.     public function getCulture(): ?Culture
  199.     {
  200.         return $this->culture;
  201.     }
  202.     public function setCulture(?Culture $culture): self
  203.     {
  204.         $this->culture $culture;
  205.         return $this;
  206.     }
  207.     public function getSeason(): ?Season
  208.     {
  209.         return $this->season;
  210.     }
  211.     public function setSeason(?Season $season): self
  212.     {
  213.         $this->season $season;
  214.         return $this;
  215.     }
  216.     public function getHash(): ?string
  217.     {
  218.         return $this->hash;
  219.     }
  220.     public function setHash(): self
  221.     {
  222.        $this->hash md5(date('YmdHis') . microtime(true) . rand(0999999));
  223.         return $this;
  224.     }
  225.     public function getOwner(): ?User
  226.     {
  227.         return $this->owner;
  228.     }
  229.     public function setOwner(?User $owner): self
  230.     {
  231.         $this->owner $owner;
  232.         return $this;
  233.     }
  234.     public function getViewer(): ?User
  235.     {
  236.         return $this->viewer;
  237.     }
  238.     public function setViewer(?User $viewer): self
  239.     {
  240.         $this->viewer $viewer;
  241.         return $this;
  242.     }
  243.     public function isRemoved(): ?bool
  244.     {
  245.         return $this->removed;
  246.     }
  247.     public function setRemoved(bool $removed): self
  248.     {
  249.         $this->removed $removed;
  250.         return $this;
  251.     }
  252.     public function getReport(): ?Report
  253.     {
  254.         return $this->report;
  255.     }
  256.     public function setReport(?Report $report): self
  257.     {
  258.         $this->report $report;
  259.         return $this;
  260.     }
  261.     public function getReportValue(): ?ReportValue
  262.     {
  263.         return $this->reportValue;
  264.     }
  265.     public function setReportValue(?ReportValue $reportValue): self
  266.     {
  267.         $this->reportValue $reportValue;
  268.         return $this;
  269.     }
  270.     public function getCompletedAt(): ?\DateTimeInterface
  271.     {
  272.         return $this->completedAt;
  273.     }
  274.     public function setCompletedAt(?\DateTimeInterface $completedAt): self
  275.     {
  276.         $this->completedAt $completedAt;
  277.         return $this;
  278.     }
  279.     public function isCustom(): ?bool
  280.     {
  281.         return $this->custom;
  282.     }
  283.     public function setCustom(?bool $custom): self
  284.     {
  285.         $this->custom $custom;
  286.         return $this;
  287.     }
  288.     public function getParameterId(): ?int
  289.     {
  290.         return $this->parameterId;
  291.     }
  292.     public function setParameterId(?int $parameterId): self
  293.     {
  294.         $this->parameterId $parameterId;
  295.         return $this;
  296.     }
  297.     /**
  298.      * @return Collection<int, Image>
  299.      */
  300.     public function getImages(): Collection
  301.     {
  302.         return $this->images;
  303.     }
  304.     public function addImage(Image $image): self
  305.     {
  306.         if (!$this->images->contains($image)) {
  307.             $this->images[] = $image;
  308.             $image->setRecommendation($this);
  309.         }
  310.         return $this;
  311.     }
  312.     public function removeImage(Image $image): self
  313.     {
  314.         if ($this->images->removeElement($image)) {
  315.             // set the owning side to null (unless already changed)
  316.             if ($image->getRecommendation() === $this) {
  317.                 $image->setRecommendation(null);
  318.             }
  319.         }
  320.         return $this;
  321.     }
  322. }