src/Entity/Review.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ReviewRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity(repositoryClass=ReviewRepository::class)
  8.  */
  9. class Review
  10. {
  11.     const STATUS_NEW 0;
  12.     const STATUS_APPROVE 1;
  13.     const STATUS_REJECT 2;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="reviews")
  22.      * @ORM\JoinColumn(nullable=false)
  23.      * @Assert\NotBlank()
  24.      */
  25.     private $user;
  26.     /**
  27.      * @ORM\Column(type="float")
  28.      * @Assert\NotBlank()
  29.      */
  30.     private $rating 0;
  31.     /**
  32.      * @ORM\Column(type="datetime")
  33.      * @Assert\NotBlank()
  34.      */
  35.     private $date;
  36.     /**
  37.      * @ORM\Column(type="text", nullable=true)
  38.      */
  39.     private $text;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=Speaker::class, inversedBy="reviews")
  42.      * @ORM\JoinColumn(nullable=false)
  43.      * @Assert\NotBlank()
  44.      */
  45.     private $speaker;
  46.     /**
  47.      * @ORM\Column(type="json", nullable=true)
  48.      */
  49.     private $ratingDetail = [];
  50.     /**
  51.      * @ORM\Column(type="integer")
  52.      */
  53.     private $status;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=SpeakerConsultation::class, inversedBy="reviews")
  56.      */
  57.     private $consultation;
  58.     public function __construct()
  59.     {
  60.         $this->date = new \DateTime();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getUser(): ?User
  67.     {
  68.         return $this->user;
  69.     }
  70.     public function setUser(?User $user): self
  71.     {
  72.         $this->user $user;
  73.         return $this;
  74.     }
  75.     public function getRating(): ?float
  76.     {
  77.         return $this->rating;
  78.     }
  79.     public function getRatingAsText(): ?string
  80.     {
  81.         return (string)$this->rating;
  82.     }
  83.     public function setRating(float $rating): self
  84.     {
  85.         $this->rating $rating;
  86.         return $this;
  87.     }
  88.     public function getDate(): ?\DateTimeInterface
  89.     {
  90.         return $this->date;
  91.     }
  92.     public function setDate(\DateTimeInterface $date): self
  93.     {
  94.         $this->date $date;
  95.         return $this;
  96.     }
  97.     public function getText(): ?string
  98.     {
  99.         return $this->text;
  100.     }
  101.     public function setText(string $text): self
  102.     {
  103.         $this->text $text;
  104.         return $this;
  105.     }
  106.     public function getSpeaker(): ?Speaker
  107.     {
  108.         return $this->speaker;
  109.     }
  110.     public function setSpeaker(?Speaker $speaker): self
  111.     {
  112.         $this->speaker $speaker;
  113.         return $this;
  114.     }
  115.     public function getRatingDetail(): ?array
  116.     {
  117.         return $this->ratingDetail;
  118.     }
  119.     public function setRatingDetail(?array $ratingDetail): self
  120.     {
  121.         $this->ratingDetail $ratingDetail;
  122.         return $this;
  123.     }
  124.     public function getStatus(): ?int
  125.     {
  126.         return $this->status;
  127.     }
  128.     public function setStatus(int $status): self
  129.     {
  130.         $this->status $status;
  131.         return $this;
  132.     }
  133.     public function isApproved(): bool
  134.     {
  135.         return $this->status === self::STATUS_APPROVE;
  136.     }
  137.     public function getConsultation(): ?SpeakerConsultation
  138.     {
  139.         return $this->consultation;
  140.     }
  141.     public function setConsultation(?SpeakerConsultation $consultation): self
  142.     {
  143.         $this->consultation $consultation;
  144.         return $this;
  145.     }
  146. }