<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\ChatLogRepository;
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=ChatLogRepository::class)
* @ApiResource(
* normalizationContext={
* "groups"={"chat_log:read"}
* },
* denormalizationContext={
* "groups"={"chat_log:write"}
* },
* itemOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "patch"={
* "security"="is_granted('ROLE_USER')"
* },
* "delete"={
* "security"="is_granted('ROLE_USER')"
* }
* },
* collectionOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "post"={
* "security"="is_granted('ROLE_USER')"
* }
* }
* )
*/
class ChatLog
{
const TYPE_READ = "read";
const TYPES = [
self::TYPE_READ => self::TYPE_READ,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @ApiProperty(identifier=true)
* @Groups({"chat_log:read", "chat_log:read:id"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255, nullable=true, options={"default": "read"})
* @Groups({"chat_log:read", "chat_log:write", "chat_log:read:type"})
* @Assert\NotBlank
*/
private ?string $type = self::TYPE_READ;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": 0})
* @Groups({"chat_log:read", "chat_log:write", "chat_log:read:value"})
*/
private ?int $value = 0;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @Assert\NotBlank
* @Groups({"chat_log:read", "chat_log:write", "chat_log:read:user"})
*/
private ?User $user;
/**
* @ORM\ManyToOne(targetEntity=Chat::class)
* @Assert\NotBlank
* @Groups({"chat_log:read", "chat_log:write", "chat_log:read:chat"})
*/
private ?Chat $chat;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="create")
* @Groups({"chat_log:read", "chat_log:read:createdAt"})
*/
private $createdAt;
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getValue(): ?int
{
return $this->value;
}
public function setValue(?int $value): self
{
$this->value = $value;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getChat(): ?Chat
{
return $this->chat;
}
public function setChat(?Chat $chat): self
{
$this->chat = $chat;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}