src/Entity/Shop/Product/ProductReview.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Product;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Generic\Customer\Customer;
  5. use App\Repository\Shop\Product\ProductReviewRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  11. #[ORM\Entity(repositoryClassProductReviewRepository::class)]
  12. class ProductReview extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'guid'uniquetrue)]
  16.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  17.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  18.     private ?string $id;
  19.     #[ORM\ManyToOne(inversedBy'productReviews')]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private ?Product $product null;
  22.     #[ORM\ManyToOne(inversedBy'productReviews')]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private ?Customer $author null;
  25.     #[ORM\Column(typeTypes::TEXT)]
  26.     private ?string $content null;
  27.     #[ORM\Column]
  28.     private array $pros = [];
  29.     #[ORM\Column]
  30.     private array $cons = [];
  31.     #[ORM\Column]
  32.     private ?int $rating null;
  33.     #[ORM\Column]
  34.     private ?bool $recommend null;
  35.     #[ORM\Column]
  36.     private ?bool $approved null;
  37.     #[ORM\OneToMany(mappedBy'review'targetEntityProductReviewVote::class)]
  38.     private Collection $productReviewVotes;
  39.     #[ORM\OneToMany(mappedBy'review'targetEntityProductReviewReply::class)]
  40.     private Collection $productReviewReplies;
  41.     public function __construct()
  42.     {
  43.         parent::__construct();
  44.         $this->setApproved(0);
  45.         $this->productReviewVotes = new ArrayCollection();
  46.         $this->productReviewReplies = new ArrayCollection();
  47.     }
  48.     public function getId(): ?string
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getProduct(): ?Product
  53.     {
  54.         return $this->product;
  55.     }
  56.     public function setProduct(?Product $product): static
  57.     {
  58.         $this->product $product;
  59.         return $this;
  60.     }
  61.     public function getAuthor(): ?Customer
  62.     {
  63.         return $this->author;
  64.     }
  65.     public function setAuthor(?Customer $author): static
  66.     {
  67.         $this->author $author;
  68.         return $this;
  69.     }
  70.     public function getContent(): ?string
  71.     {
  72.         return $this->content;
  73.     }
  74.     public function setContent(string $content): static
  75.     {
  76.         $this->content $content;
  77.         return $this;
  78.     }
  79.     public function getPros(): array
  80.     {
  81.         return $this->pros;
  82.     }
  83.     public function setPros(array $pros): static
  84.     {
  85.         $this->pros $pros;
  86.         return $this;
  87.     }
  88.     public function getCons(): array
  89.     {
  90.         return $this->cons;
  91.     }
  92.     public function setCons(array $cons): static
  93.     {
  94.         $this->cons $cons;
  95.         return $this;
  96.     }
  97.     public function getRating(): ?int
  98.     {
  99.         return $this->rating;
  100.     }
  101.     public function setRating(int $rating): static
  102.     {
  103.         $this->rating $rating;
  104.         return $this;
  105.     }
  106.     public function isRecommend(): ?bool
  107.     {
  108.         return $this->recommend;
  109.     }
  110.     public function setRecommend(bool $recommend): static
  111.     {
  112.         $this->recommend $recommend;
  113.         return $this;
  114.     }
  115.     public function isApproved(): ?bool
  116.     {
  117.         return $this->approved;
  118.     }
  119.     public function setApproved(bool $approved): static
  120.     {
  121.         $this->approved $approved;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Collection<int, ProductReviewVote>
  126.      */
  127.     public function getProductReviewVotes(): Collection
  128.     {
  129.         return $this->productReviewVotes;
  130.     }
  131.     public function addProductReviewVote(ProductReviewVote $productReviewVote): static
  132.     {
  133.         if (!$this->productReviewVotes->contains($productReviewVote)) {
  134.             $this->productReviewVotes->add($productReviewVote);
  135.             $productReviewVote->setReview($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeProductReviewVote(ProductReviewVote $productReviewVote): static
  140.     {
  141.         if ($this->productReviewVotes->removeElement($productReviewVote)) {
  142.             // set the owning side to null (unless already changed)
  143.             if ($productReviewVote->getReview() === $this) {
  144.                 $productReviewVote->setReview(null);
  145.             }
  146.         }
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, ProductReviewReply>
  151.      */
  152.     public function getProductReviewReplies(): Collection
  153.     {
  154.         return $this->productReviewReplies;
  155.     }
  156.     public function addProductReviewReply(ProductReviewReply $productReviewReply): static
  157.     {
  158.         if (!$this->productReviewReplies->contains($productReviewReply)) {
  159.             $this->productReviewReplies->add($productReviewReply);
  160.             $productReviewReply->setReview($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeProductReviewReply(ProductReviewReply $productReviewReply): static
  165.     {
  166.         if ($this->productReviewReplies->removeElement($productReviewReply)) {
  167.             // set the owning side to null (unless already changed)
  168.             if ($productReviewReply->getReview() === $this) {
  169.                 $productReviewReply->setReview(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174. }