<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
use ApiPlatform\Core\Serializer\Filter\GroupFilter;
use App\Repository\PedometerLogRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=PedometerLogRepository::class)
* @ApiResource(
* normalizationContext={"groups"={"pedometer_log:read"}},
* denormalizationContext={"groups"={"pedometer_log:write"}},
* itemOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "patch"={
* "security"="is_granted('ROLE_USER')"
* },
* "delete"={
* "security"="is_granted('ROLE_ADMIN')"
* }
* },
* collectionOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "post"={
* "security"="is_granted('ROLE_USER')"
* }
* }
* )
* @UniqueEntity(
* fields={"user", "dateStart", "dateEnd"},
* message="pedometer.log.unique_entity",
* )
*/
class PedometerLog
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"pedometer_log:read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="pedometerLogs")
* @Groups({"pedometer_log:read", "pedometer_log:write"})
*/
private $tvUser;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="pedometerLogs")
* @Assert\NotNull
* @Groups({"pedometer_log:read", "pedometer_log:write"})
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="pedometerLogs")
* @Groups({"pedometer_log:read"})
*/
private $tvCompany;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="pedometerLogs")
* @Groups({"pedometer_log:read"})
*/
private $company;
/**
* @ORM\Column(type="integer", nullable=true)
* @Assert\NotNull
* @Groups({"pedometer_log:read", "pedometer_log:write"})
*/
private $stepAmount;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"pedometer_log:read", "pedometer_log:write"})
*/
private $dateStart;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"pedometer_log:read", "pedometer_log:write"})
*/
private $dateEnd;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
* @Gedmo\Timestampable(on="create")
* @Groups({"pedometer_log: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 getTvCompany(): ?TvCompany
{
return $this->tvCompany;
}
public function setTvCompany(?TvCompany $tvCompany): self
{
$this->tvCompany = $tvCompany;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getStepAmount(): ?int
{
return $this->stepAmount;
}
public function setStepAmount(?int $stepAmount): self
{
$this->stepAmount = $stepAmount;
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(?\DateTimeInterface $dateStart): self
{
$this->dateStart = $dateStart;
return $this;
}
public function getDateEnd(): ?\DateTimeInterface
{
return $this->dateEnd;
}
public function setDateEnd(?\DateTimeInterface $dateEnd): self
{
$this->dateEnd = $dateEnd;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}