src/Entity/SessionQuestionLike.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Filter\UserFilter;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use ApiPlatform\Core\Annotation\ApiFilter;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. use App\Entity\Interfaces\LikeEntityInterface;
  9. use App\Entity\Interfaces\OwnerMappedInterface;
  10. use App\Repository\SessionQuestionLikeRepository;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  13. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  14. /**
  15.  * @ApiResource(
  16.  *      attributes={"security"="is_granted('IS_AUTHENTICATED_FULLY')"},
  17.  *      normalizationContext={"groups"={"SessionQuestionLike:Read"}, "skip_null_values"=false},
  18.  *      collectionOperations={
  19.  *          "get"
  20.  *      },
  21.  *      itemOperations={
  22.  *          "get"
  23.  *      }
  24.  * )
  25.  * @ApiFilter(SearchFilter::class, properties={"user.id": "exact", "sessionQuestion.id": "exact"})
  26.  * @ApiFilter(UserFilter::class, properties={"search": "partial"})
  27.  * @ApiFilter(OrderFilter::class, properties={"id": "DESC"})
  28.  * @ORM\Entity(repositoryClass=SessionQuestionLikeRepository::class)
  29.  */
  30. class SessionQuestionLike implements LikeEntityInterfaceOwnerMappedInterface
  31. {
  32.     /**
  33.      * @var \DateTime
  34.      * @Gedmo\Timestampable(on="create")
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     protected $createdAt;
  38.     /**
  39.      * Sets createdAt.
  40.      *
  41.      * @return $this
  42.      */
  43.     public function setCreatedAt(\DateTime $createdAt)
  44.     {
  45.         $this->createdAt $createdAt;
  46.         return $this;
  47.     }
  48.     /**
  49.      * Returns createdAt.
  50.      *
  51.      * @return \DateTime
  52.      */
  53.     public function getCreatedAt()
  54.     {
  55.         return $this->createdAt;
  56.     }
  57.     /**
  58.      * @ORM\Id
  59.      * @ORM\GeneratedValue
  60.      * @ORM\Column(type="integer")
  61.      */
  62.     private $id;
  63.     /**
  64.      * @ORM\ManyToOne(targetEntity=SessionQuestion::class)
  65.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  66.      * @Groups({"User:Me-Subscribed"})
  67.      */
  68.     private $sessionQuestion;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="sessionQuestionLikes")
  71.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  72.      * @Groups({"SessionQuestionLike:Read"})
  73.      */
  74.     private $user;
  75.     public function __construct($sessionQuestion null$user null)
  76.     {
  77.         if ($sessionQuestion) {
  78.             $this->sessionQuestion $sessionQuestion;
  79.         }
  80.         if ($user) {
  81.             $this->user $user;
  82.         }
  83.     }
  84.     public function getId(): ?int
  85.     {
  86.         return $this->id;
  87.     }
  88.     public function getSessionQuestion(): ?SessionQuestion
  89.     {
  90.         return $this->sessionQuestion;
  91.     }
  92.     public function setSessionQuestion(?SessionQuestion $sessionQuestion): self
  93.     {
  94.         $this->sessionQuestion $sessionQuestion;
  95.         return $this;
  96.     }
  97.     public function getUser(): ?User
  98.     {
  99.         return $this->user;
  100.     }
  101.     public function setUser(?User $user): self
  102.     {
  103.         $this->user $user;
  104.         return $this;
  105.     }
  106.     public function getParent()
  107.     {
  108.         return $this->getSessionQuestion();
  109.     }
  110.     public function getParentClass()
  111.     {
  112.         return SessionQuestion::class;
  113.     }
  114. }