<?php
namespace App\Entity;
use App\Repository\ShopReviewVoteRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ShopReviewVoteRepository::class)]
#[ORM\Table(name: 'shop_review_votes')]
#[ORM\UniqueConstraint(name: 'unique_user_review_vote', columns: ['user_id', 'review_id'])]
class ShopReviewVote
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
#[ORM\ManyToOne(targetEntity: ShopReview::class, inversedBy: 'votes')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?ShopReview $review = null;
#[ORM\Column(type: Types::BOOLEAN)]
private bool $isHelpful = false;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private ?\DateTimeImmutable $createdAt = null;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getReview(): ?ShopReview
{
return $this->review;
}
public function setReview(?ShopReview $review): static
{
$this->review = $review;
return $this;
}
public function isHelpful(): bool
{
return $this->isHelpful;
}
public function setIsHelpful(bool $isHelpful): static
{
$this->isHelpful = $isHelpful;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
}