<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
use App\Annotation\SerializedNameGroups;
use App\Repository\MoodResponseRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=MoodResponseRepository::class)
* @ApiResource(
* normalizationContext={"groups"={"mood_response:read"}},
* denormalizationContext={"groups"={"mood_response:write"}},
* itemOperations={
* "get"={"security"="is_granted('ROLE_USER')"},
* "patch"={"security"="is_granted('ROLE_ADMIN')"},
* "delete"={"security"="is_granted('ROLE_ADMIN')"}
* },
* collectionOperations={
* "get"={"security"="is_granted('ROLE_USER')"},
* "post"={"security"="is_granted('ROLE_USER')"},
* "post_front"={
* "method"="POST",
* "path"="/custom/mood_responses",
* "description"="Post a mood_response with a custom response",
* "controller"="App\Controller\Api\MoodResponsesController::postFrontMoodResponses",
* "security"="is_granted('ROLE_USER')"
* }
* }
* )
* @ApiFilter(OrderFilter::class)
* @ApiFilter(SearchFilter::class)
* @ApiFilter(DateFilter::class)
*/
class MoodResponse
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"mood_response:read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="moodResponses")
* @ORM\JoinColumn(nullable=true)
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $tvUser;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="moodResponses")
* @ORM\JoinColumn(nullable=true)
* @Assert\NotNull
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $user;
/**
* @ORM\Column(type="integer")
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $moodId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $moodImg;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $moodName;
/**
* @ORM\Column(type="integer")
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $answerId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"mood_response:read", "mood_response:write"})
*/
private $answerName;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
* @Groups({"mood_response:read"})
*/
private $createdAt;
public function getId(): ?int
{
return $this->id;
}
public function getTvUser(): ?TvUser
{
return $this->tvUser;
}
public function setTvUser(?TvUser $tvUser): self
{
$this->tvUser = $tvUser;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getMoodId(): ?int
{
return $this->moodId;
}
public function setMoodId(int $moodId): self
{
$this->moodId = $moodId;
return $this;
}
public function getMoodImg(): ?string
{
return $this->moodImg;
}
public function setMoodImg(?string $moodImg): self
{
$this->moodImg = $moodImg;
return $this;
}
public function getMoodName(): ?string
{
return $this->moodName;
}
public function setMoodName(string $moodName): self
{
$this->moodName = $moodName;
return $this;
}
public function getAnswerId(): ?int
{
return $this->answerId;
}
public function setAnswerId(int $answerId): self
{
$this->answerId = $answerId;
return $this;
}
public function getAnswerName(): ?string
{
return $this->answerName;
}
public function setAnswerName(?string $answerName): self
{
$this->answerName = $answerName;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}