src/Entity/UserActivityLog.php line 28

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\Serializer\Filter\PropertyFilter;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\UserActivityLogRepository")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. #[ApiResource(
  16.     attributes: ['security' => "is_granted('ROLE_USER')"],
  17.     normalizationContext: ['groups' => ['userActivityLog:read']],
  18.     collectionOperations: ['get'],
  19.     itemOperations: ['get'],
  20. )]
  21. #[ApiFilter(SearchFilter::class, properties: ['old_value' => 'partial''new_value' => 'partial''activity' => 'partial''user' => 'exact''surveyCompany' => 'exact'])]
  22. #[ApiFilter(PropertyFilter::class)]
  23. #[ApiFilter(OrderFilter::class, properties: ['id''old_value''new_value''user''surveyCompany''activity''createdAt'], arguments: ['orderParameterName' => 'order'])]
  24. class UserActivityLog
  25. {
  26.     use TimestampableEntity;
  27.     /**
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @var User
  35.      *
  36.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="userActivitylog")
  37.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  38.      * @Groups({"userActivityLog:read"})
  39.      */
  40.     private $user;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      * @Groups({"userActivityLog:read"})
  44.      */
  45.     private $activity;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      * @Groups({"userActivityLog:read"})
  49.      */
  50.     private $old_value;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      * @Groups({"userActivityLog:read"})
  54.      */
  55.     private $new_value;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity=SurveyCompany::class)
  58.      * @Groups({"userActivityLog:read"})
  59.      */
  60.     private $surveyCompany;
  61.     /**
  62.      * UserActivityLog constructor.
  63.      *
  64.      * @throws Exception
  65.      */
  66.     public function __construct()
  67.     {
  68.         $this->createdAt = new \DateTime();
  69.         $this->updatedAt = new \DateTime();
  70.     }
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getUser(): ?User
  76.     {
  77.         return $this->user;
  78.     }
  79.     public function setUser(?User $user): self
  80.     {
  81.         $this->user $user;
  82.         return $this;
  83.     }
  84.     public function getActivity(): ?string
  85.     {
  86.         return $this->activity;
  87.     }
  88.     public function setActivity(?string $activity): self
  89.     {
  90.         $this->activity $activity;
  91.         return $this;
  92.     }
  93.     public function getOldValue(): ?string
  94.     {
  95.         return $this->old_value;
  96.     }
  97.     public function setOldValue(?string $old_value): self
  98.     {
  99.         $this->old_value $old_value;
  100.         return $this;
  101.     }
  102.     public function getNewValue(): ?string
  103.     {
  104.         return $this->new_value;
  105.     }
  106.     public function setNewValue(?string $new_value): self
  107.     {
  108.         $this->new_value $new_value;
  109.         return $this;
  110.     }
  111.     public function getSurveyCompany(): ?SurveyCompany
  112.     {
  113.         return $this->surveyCompany;
  114.     }
  115.     public function setSurveyCompany(?SurveyCompany $surveyCompany): self
  116.     {
  117.         $this->surveyCompany $surveyCompany;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @Groups({"userActivityLog:read"})
  122.      */
  123.     public function getCreatedAt(): ?\DateTimeInterface
  124.     {
  125.         return $this->createdAt;
  126.     }
  127. }