<?php
namespace App\Entity;
use App\Repository\ReviewRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=ReviewRepository::class)
*/
class Review
{
const STATUS_NEW = 0;
const STATUS_APPROVE = 1;
const STATUS_REJECT = 2;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="reviews")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
*/
private $user;
/**
* @ORM\Column(type="float")
* @Assert\NotBlank()
*/
private $rating = 0;
/**
* @ORM\Column(type="datetime")
* @Assert\NotBlank()
*/
private $date;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $text;
/**
* @ORM\ManyToOne(targetEntity=Speaker::class, inversedBy="reviews")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
*/
private $speaker;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $ratingDetail = [];
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\ManyToOne(targetEntity=SpeakerConsultation::class, inversedBy="reviews")
*/
private $consultation;
public function __construct()
{
$this->date = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getRating(): ?float
{
return $this->rating;
}
public function getRatingAsText(): ?string
{
return (string)$this->rating;
}
public function setRating(float $rating): self
{
$this->rating = $rating;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
public function getSpeaker(): ?Speaker
{
return $this->speaker;
}
public function setSpeaker(?Speaker $speaker): self
{
$this->speaker = $speaker;
return $this;
}
public function getRatingDetail(): ?array
{
return $this->ratingDetail;
}
public function setRatingDetail(?array $ratingDetail): self
{
$this->ratingDetail = $ratingDetail;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function isApproved(): bool
{
return $this->status === self::STATUS_APPROVE;
}
public function getConsultation(): ?SpeakerConsultation
{
return $this->consultation;
}
public function setConsultation(?SpeakerConsultation $consultation): self
{
$this->consultation = $consultation;
return $this;
}
}