src/Entity/Refill.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RefillRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use ApiPlatform\Action\NotFoundAction;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\ApiResource;
  11. use Symfony\Component\Serializer\Annotation\MaxDepth;
  12. #[ApiResource(
  13.     normalizationContext: ['enable_max_depth'=>true],
  14. )]
  15. #[ORM\Entity(repositoryClassRefillRepository::class)]
  16. class Refill
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     #[MaxDepth(1)]
  23.     #[ORM\ManyToOne(inversedBy'refills')]
  24.     private ?User $user null;
  25.     #[MaxDepth(1)]
  26.     #[ORM\ManyToOne(inversedBy'refills')]
  27.     private ?Channel $channel null;
  28.     #[MaxDepth(1)]
  29.     #[ORM\ManyToOne]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private ?EntityName $entity null;
  32.     #[ORM\ManyToOne]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private ?Action $action null;
  35.     #[ORM\Column]
  36.     private ?int $quantity null;
  37.     #[ORM\Column]
  38.     private ?int $used null;
  39.     #[ORM\Column]
  40.     private ?int $createdDate null;
  41.     #[ORM\Column(nullabletrue)]
  42.     private ?int $expireDate null;
  43.     #[ORM\OneToOne(mappedBy'refill'cascade: ['persist''remove'])]
  44.     private ?RefillAmend $refillAmend null;
  45.     public function __construct()
  46.     {
  47.         $this->used 0;
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getUser(): ?User
  54.     {
  55.         return $this->user;
  56.     }
  57.     public function setUser(?User $user): self
  58.     {
  59.         $this->user $user;
  60.         return $this;
  61.     }
  62.     public function getChannel(): ?Channel
  63.     {
  64.         return $this->channel;
  65.     }
  66.     public function setChannel(?Channel $channel): self
  67.     {
  68.         $this->channel $channel;
  69.         return $this;
  70.     }
  71.     public function getEntity(): ?EntityName
  72.     {
  73.         return $this->entity;
  74.     }
  75.     public function setEntity(?EntityName $entity): self
  76.     {
  77.         $this->entity $entity;
  78.         return $this;
  79.     }
  80.     public function getAction(): ?Action
  81.     {
  82.         return $this->action;
  83.     }
  84.     public function setAction(?Action $action): self
  85.     {
  86.         $this->action $action;
  87.         return $this;
  88.     }
  89.     public function getQuantity(): ?int
  90.     {
  91.         return $this->quantity;
  92.     }
  93.     public function setQuantity(int $quantity): self
  94.     {
  95.         $this->quantity $quantity;
  96.         return $this;
  97.     }
  98.     public function getUsed(): ?int
  99.     {
  100.         return $this->used;
  101.     }
  102.     public function setUsed(int $used): self
  103.     {
  104.         $this->used $used;
  105.         return $this;
  106.     }
  107.     public function getCreatedDate(): ?int
  108.     {
  109.         return $this->createdDate;
  110.     }
  111.     public function setCreatedDate(int $createdDate): self
  112.     {
  113.         $this->createdDate $createdDate;
  114.         return $this;
  115.     }
  116.     public function getExpireDate(): ?int
  117.     {
  118.         return $this->expireDate;
  119.     }
  120.     public function setExpireDate(?int $expireDate): self
  121.     {
  122.         $this->expireDate $expireDate;
  123.         return $this;
  124.     }
  125.     public function getRefillAmend(): ?RefillAmend
  126.     {
  127.         return $this->refillAmend;
  128.     }
  129.     public function setRefillAmend(RefillAmend $refillAmend): self
  130.     {
  131.         // set the owning side of the relation if necessary
  132.         if ($refillAmend->getRefill() !== $this) {
  133.             $refillAmend->setRefill($this);
  134.         }
  135.         $this->refillAmend $refillAmend;
  136.         return $this;
  137.     }
  138.     public function __toString()
  139.     {
  140.         return "Refill {$this->id} - Channel {$this->channel}";
  141.     }
  142. }