src/Entity/ContentRanking.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\ORM\Mapping\JoinColumn;
  5. use Doctrine\ORM\Mapping\OneToOne;
  6. use JMS\Serializer\Annotation\Groups;
  7. /**
  8.  * @ORM\Table(name="ContentRanking", indexes={
  9.  *
  10.  *   @ORM\Index(name="created_at_idx", columns={"created_at"}),
  11.  *   @ORM\Index(name="updated_at_idx", columns={"updated_at"}),
  12.  *   @ORM\Index(name="rank_idx", columns={"rank"}),
  13.  *   @ORM\Index(name="rank_updated_at_idx", columns={"rank", "updated_at"}),
  14.  *   @ORM\Index(name="rank_created_at_idx", columns={"rank", "created_at"})
  15.  * })
  16.  *
  17.  * @ORM\Entity(repositoryClass="App\Repository\ContentRankingRepository")
  18.  *
  19.  * @ORM\HasLifecycleCallbacks()
  20.  */
  21. class ContentRanking
  22. {
  23.     /**
  24.      * @Groups({"contentlist"})
  25.      *
  26.      * @ORM\Id()
  27.      *
  28.      * @ORM\GeneratedValue()
  29.      *
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @var int
  35.      *
  36.      * @ORM\Column(type="integer", nullable=true)
  37.      */
  38.     private $votes 0;
  39.     /**
  40.      * @Groups({"contentlist", "video_search", "imageset_search"})
  41.      *
  42.      * @var int
  43.      *
  44.      * @ORM\Column(type="integer", nullable=true)
  45.      */
  46.     private $vote_average;
  47.     /**
  48.      * @var int
  49.      *
  50.      * @ORM\Column(type="integer", nullable=true)
  51.      */
  52.     private $comment_count 0;
  53.     /**
  54.      * @var int
  55.      *
  56.      * @ORM\Column(type="integer", nullable=true)
  57.      */
  58.     private $like_count;
  59.     /**
  60.      * @var int
  61.      *
  62.      * @ORM\Column(type="integer", nullable=true)
  63.      */
  64.     private $sell_count 0;
  65.     /**
  66.      * @var int
  67.      *
  68.      * @Groups({"video_search", "imageset_search"})
  69.      *
  70.      * @ORM\Column(type="integer", nullable=false)
  71.      */
  72.     private $rank 0;
  73.     /**
  74.      * @var float
  75.      *
  76.      * @ORM\Column(type="float", nullable=true)
  77.      */
  78.     private $rank_modifier;
  79.     /**
  80.      * @OneToOne(targetEntity="Content", inversedBy="ranking")
  81.      *
  82.      * @JoinColumn(name="content_id", referencedColumnName="id", onDelete="CASCADE")
  83.      */
  84.     protected $content;
  85.     /**
  86.      * @var \DateTime
  87.      *
  88.      * @ORM\Column(type="datetime")
  89.      */
  90.     private $created_at;
  91.     /**
  92.      * @var \DateTime
  93.      *
  94.      * @ORM\Column(type="datetime")
  95.      */
  96.     private $updated_at;
  97.     /**
  98.      * @ORM\PrePersist()
  99.      */
  100.     public function prePersist()
  101.     {
  102.         if (!$this->getCreatedAt()) {
  103.             $this->created_at = new \DateTime();
  104.         }
  105.         if (!$this->getUpdatedAt()) {
  106.             $this->setUpdatedAt(new \DateTime());
  107.         }
  108.     }
  109.     public function getId()
  110.     {
  111.         return $this->id;
  112.     }
  113.     public function setCommentCount(int $comment_count): self
  114.     {
  115.         $this->comment_count $comment_count;
  116.         return $this;
  117.     }
  118.     public function getCommentCount(): int
  119.     {
  120.         return $this->comment_count ?? 0;
  121.     }
  122.     public function setContent(Content $content): self
  123.     {
  124.         $this->content $content;
  125.         return $this;
  126.     }
  127.     public function getContent(): ?Content
  128.     {
  129.         return $this->content;
  130.     }
  131.     public function getCreatedAt(): ?\DateTime
  132.     {
  133.         return $this->created_at;
  134.     }
  135.     public function setId(int $id): self
  136.     {
  137.         $this->id $id;
  138.         return $this;
  139.     }
  140.     public function setLikeCount(int $like_count): self
  141.     {
  142.         $this->like_count $like_count;
  143.         return $this;
  144.     }
  145.     public function getLikeCount(): ?int
  146.     {
  147.         return $this->like_count;
  148.     }
  149.     public function setRank(int $rank): self
  150.     {
  151.         $this->rank $rank;
  152.         return $this;
  153.     }
  154.     public function getRank(): ?int
  155.     {
  156.         return $this->rank;
  157.     }
  158.     public function setSellCount(int $sell_count): self
  159.     {
  160.         $this->sell_count $sell_count;
  161.         return $this;
  162.     }
  163.     public function getSellCount(): int
  164.     {
  165.         return $this->sell_count ?? 0;
  166.     }
  167.     public function setUpdatedAt(?\DateTime $updated_at): self
  168.     {
  169.         $this->updated_at $updated_at;
  170.         return $this;
  171.     }
  172.     public function getUpdatedAt(): ?\DateTime
  173.     {
  174.         return $this->updated_at;
  175.     }
  176.     public function setVoteAverage(int $vote_average): self
  177.     {
  178.         $this->vote_average $vote_average;
  179.         return $this;
  180.     }
  181.     public function getVoteAverage(): ?int
  182.     {
  183.         return $this->vote_average;
  184.     }
  185.     public function setVotes(int $votes): self
  186.     {
  187.         $this->votes $votes;
  188.         return $this;
  189.     }
  190.     public function getVotes(): int
  191.     {
  192.         return $this->votes ?? 0;
  193.     }
  194.     public function setRankModifier(int $rank_modifier): self
  195.     {
  196.         $this->rank_modifier $rank_modifier;
  197.         return $this;
  198.     }
  199.     public function getRankModifier(): ?int
  200.     {
  201.         return $this->rank_modifier;
  202.     }
  203. }