src/Entity/MoodResponse.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  8. use App\Annotation\SerializedNameGroups;
  9. use App\Repository\MoodResponseRepository;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. /**
  15.  * @ORM\Entity(repositoryClass=MoodResponseRepository::class)
  16.  * @ApiResource(
  17.  *      normalizationContext={"groups"={"mood_response:read"}},
  18.  *      denormalizationContext={"groups"={"mood_response:write"}},
  19.  *      itemOperations={
  20.  *          "get"={"security"="is_granted('ROLE_USER')"},
  21.  *          "patch"={"security"="is_granted('ROLE_ADMIN')"},
  22.  *          "delete"={"security"="is_granted('ROLE_ADMIN')"}
  23.  *      },
  24.  *      collectionOperations={
  25.  *          "get"={"security"="is_granted('ROLE_USER')"},
  26.  *          "post"={"security"="is_granted('ROLE_USER')"},
  27.  *          "post_front"={
  28.  *             "method"="POST",
  29.  *             "path"="/custom/mood_responses",
  30.  *             "description"="Post a mood_response with a custom response",
  31.  *             "controller"="App\Controller\Api\MoodResponsesController::postFrontMoodResponses",
  32.  *             "security"="is_granted('ROLE_USER')"    
  33.  *          }
  34.  *      }
  35.  * )
  36.  * @ApiFilter(OrderFilter::class)
  37.  * @ApiFilter(SearchFilter::class)
  38.  * @ApiFilter(DateFilter::class)
  39.  */
  40. class MoodResponse
  41. {
  42.     /**
  43.      * @ORM\Id
  44.      * @ORM\GeneratedValue
  45.      * @ORM\Column(type="integer")
  46.      * @Groups({"mood_response:read"})
  47.      */
  48.     private $id;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="moodResponses")
  51.      * @ORM\JoinColumn(nullable=true)
  52.      * @Groups({"mood_response:read", "mood_response:write"})
  53.      */
  54.     private $tvUser;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="moodResponses")
  57.      * @ORM\JoinColumn(nullable=true)
  58.      * @Assert\NotNull
  59.      * @Groups({"mood_response:read", "mood_response:write"})
  60.      */
  61.     private $user;
  62.     /**
  63.      * @ORM\Column(type="integer")
  64.      * @Groups({"mood_response:read", "mood_response:write"})
  65.      */
  66.     private $moodId;
  67.     /**
  68.      * @ORM\Column(type="string", length=255, nullable=true)
  69.      * @Groups({"mood_response:read", "mood_response:write"})
  70.      */
  71.     private $moodImg;
  72.     /**
  73.      * @ORM\Column(type="string", length=255)
  74.      * @Groups({"mood_response:read", "mood_response:write"})
  75.      */
  76.     private $moodName;
  77.     /**
  78.      * @ORM\Column(type="integer")
  79.      * @Groups({"mood_response:read", "mood_response:write"})
  80.      */
  81.     private $answerId;
  82.     /**
  83.      * @ORM\Column(type="string", length=255, nullable=true)
  84.      * @Groups({"mood_response:read", "mood_response:write"})
  85.      */
  86.     private $answerName;
  87.     /**
  88.      * @ORM\Column(type="datetime")
  89.      * @Gedmo\Timestampable(on="create")
  90.      * @Groups({"mood_response:read"})
  91.      */
  92.     private $createdAt;
  93.     
  94.     public function getId(): ?int
  95.     {
  96.         return $this->id;
  97.     }
  98.     public function getTvUser(): ?TvUser
  99.     {
  100.         return $this->tvUser;
  101.     }
  102.     public function setTvUser(?TvUser $tvUser): self
  103.     {
  104.         $this->tvUser $tvUser;
  105.         return $this;
  106.     }
  107.     public function getUser(): ?User
  108.     {
  109.         return $this->user;
  110.     }
  111.     public function setUser(?User $user): self
  112.     {
  113.         $this->user $user;
  114.         return $this;
  115.     }
  116.     public function getMoodId(): ?int
  117.     {
  118.         return $this->moodId;
  119.     }
  120.     public function setMoodId(int $moodId): self
  121.     {
  122.         $this->moodId $moodId;
  123.         return $this;
  124.     }
  125.     public function getMoodImg(): ?string
  126.     {
  127.         return $this->moodImg;
  128.     }
  129.     public function setMoodImg(?string $moodImg): self
  130.     {
  131.         $this->moodImg $moodImg;
  132.         return $this;
  133.     }
  134.     public function getMoodName(): ?string
  135.     {
  136.         return $this->moodName;
  137.     }
  138.     public function setMoodName(string $moodName): self
  139.     {
  140.         $this->moodName $moodName;
  141.         return $this;
  142.     }
  143.     public function getAnswerId(): ?int
  144.     {
  145.         return $this->answerId;
  146.     }
  147.     public function setAnswerId(int $answerId): self
  148.     {
  149.         $this->answerId $answerId;
  150.         return $this;
  151.     }
  152.     public function getAnswerName(): ?string
  153.     {
  154.         return $this->answerName;
  155.     }
  156.     public function setAnswerName(?string $answerName): self
  157.     {
  158.         $this->answerName $answerName;
  159.         return $this;
  160.     }
  161.     public function getCreatedAt(): ?\DateTimeInterface
  162.     {
  163.         return $this->createdAt;
  164.     }
  165.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  166.     {
  167.         $this->createdAt $createdAt;
  168.         return $this;
  169.     }
  170. }