src/Entity/PedometerLog.php line 50

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\Annotation\ApiSubresource;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
  10. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  11. use App\Repository\PedometerLogRepository;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. /**
  18.  * @ORM\Entity(repositoryClass=PedometerLogRepository::class)
  19.  * @ApiResource(
  20.  *      normalizationContext={"groups"={"pedometer_log:read"}},
  21.  *      denormalizationContext={"groups"={"pedometer_log:write"}},
  22.  *      itemOperations={
  23.  *          "get"={
  24.  *              "security"="is_granted('ROLE_USER')"
  25.  *          }, 
  26.  *          "patch"={
  27.  *              "security"="is_granted('ROLE_USER')"
  28.  *          }, 
  29.  *          "delete"={
  30.  *              "security"="is_granted('ROLE_ADMIN')"
  31.  *          }
  32.  *      },
  33.  *      collectionOperations={
  34.  *          "get"={
  35.  *              "security"="is_granted('ROLE_USER')"
  36.  *          }, 
  37.  *          "post"={
  38.  *              "security"="is_granted('ROLE_USER')"
  39.  *          }
  40.  *      }
  41.  * )
  42.  * @UniqueEntity(
  43.  *     fields={"user", "dateStart", "dateEnd"},
  44.  *     message="pedometer.log.unique_entity",
  45.  * )
  46.  */
  47. class PedometerLog
  48. {
  49.     /**
  50.      * @ORM\Id
  51.      * @ORM\GeneratedValue
  52.      * @ORM\Column(type="integer")
  53.      * @Groups({"pedometer_log:read"})
  54.      */
  55.     private $id;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="pedometerLogs")
  58.      * @Groups({"pedometer_log:read", "pedometer_log:write"})
  59.      */
  60.     private $tvUser;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="pedometerLogs")
  63.      * @Assert\NotNull
  64.      * @Groups({"pedometer_log:read", "pedometer_log:write"})
  65.      */
  66.     private $user;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="pedometerLogs")
  69.      * @Groups({"pedometer_log:read"})
  70.      */
  71.     private $tvCompany;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="pedometerLogs")
  74.      * @Groups({"pedometer_log:read"})
  75.      */
  76.     private $company;
  77.     /**
  78.      * @ORM\Column(type="integer", nullable=true)
  79.      * @Assert\NotNull
  80.      * @Groups({"pedometer_log:read", "pedometer_log:write"})
  81.      */
  82.     private $stepAmount;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true)
  85.      * @Groups({"pedometer_log:read", "pedometer_log:write"})
  86.      */
  87.     private $dateStart;
  88.     /**
  89.      * @ORM\Column(type="datetime", nullable=true)
  90.      * @Groups({"pedometer_log:read", "pedometer_log:write"})
  91.      */
  92.     private $dateEnd;
  93.     /**
  94.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  95.      * @Gedmo\Timestampable(on="create")
  96.      * @Groups({"pedometer_log:read"})
  97.      */
  98.     private $createdAt;
  99.     public function getId(): ?int
  100.     {
  101.         return $this->id;
  102.     }
  103.     public function getTvUser(): ?TvUser
  104.     {
  105.         return $this->tvUser;
  106.     }
  107.     public function setTvUser(?TvUser $tvUser): self
  108.     {
  109.         $this->tvUser $tvUser;
  110.         return $this;
  111.     }
  112.     public function getUser(): ?User
  113.     {
  114.         return $this->user;
  115.     }
  116.     public function setUser(?User $user): self
  117.     {
  118.         $this->user $user;
  119.         return $this;
  120.     }
  121.     public function getTvCompany(): ?TvCompany
  122.     {
  123.         return $this->tvCompany;
  124.     }
  125.     public function setTvCompany(?TvCompany $tvCompany): self
  126.     {
  127.         $this->tvCompany $tvCompany;
  128.         return $this;
  129.     }
  130.     public function getCompany(): ?Company
  131.     {
  132.         return $this->company;
  133.     }
  134.     public function setCompany(?Company $company): self
  135.     {
  136.         $this->company $company;
  137.         return $this;
  138.     }
  139.     public function getStepAmount(): ?int
  140.     {
  141.         return $this->stepAmount;
  142.     }
  143.     public function setStepAmount(?int $stepAmount): self
  144.     {
  145.         $this->stepAmount $stepAmount;
  146.         return $this;
  147.     }
  148.     public function getDateStart(): ?\DateTimeInterface
  149.     {
  150.         return $this->dateStart;
  151.     }
  152.     public function setDateStart(?\DateTimeInterface $dateStart): self
  153.     {
  154.         $this->dateStart $dateStart;
  155.         return $this;
  156.     }
  157.     public function getDateEnd(): ?\DateTimeInterface
  158.     {
  159.         return $this->dateEnd;
  160.     }
  161.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  162.     {
  163.         $this->dateEnd $dateEnd;
  164.         return $this;
  165.     }
  166.     public function getCreatedAt(): ?\DateTimeInterface
  167.     {
  168.         return $this->createdAt;
  169.     }
  170.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  171.     {
  172.         $this->createdAt $createdAt;
  173.         return $this;
  174.     }
  175. }