src/Flexy/ShopBundle/Entity/Customer/PackEngagement.php line 19

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Customer;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Flexy\ShopBundle\Entity\Order\OrderItem;
  7. use App\Flexy\ShopBundle\Repository\Customer\PackEngagementRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ApiResource(
  11.     normalizationContext: ['groups' => ['read']],
  12.     denormalizationContext: ['groups' => ['write']],
  13. )]
  14. #[ApiFilter(SearchFilter::class, properties: ['customer'=>'exact'])]
  15. #[ORM\Entity(repositoryClassPackEngagementRepository::class)]
  16. class PackEngagement
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     #[Groups(['read','write'])]
  22.     private $id;
  23.     #[ORM\ManyToOne(targetEntityPack::class, inversedBy'packEngagements'cascade: ['persist'])]
  24.     private ?\App\Flexy\ShopBundle\Entity\Customer\Pack $pack null;
  25.     
  26.     #[ORM\ManyToOne(targetEntityCustomer::class, inversedBy'packEngagements')]
  27.     private ?\App\Flexy\ShopBundle\Entity\Customer\Customer $customer null;
  28.     #[Groups(['read','write'])]
  29.     #[ORM\Column(type'datetime')]
  30.     private ?\DateTimeInterface $startAt null;
  31.     #[Groups(['read','write'])]
  32.     #[ORM\Column(type'datetime')]
  33.     private ?\DateTimeInterface $endAt null;
  34.    
  35.     #[ORM\OneToOne(targetEntityOrderItem::class, mappedBy'packEngagement'cascade: ['persist''remove'])]
  36.     private ?\App\Flexy\ShopBundle\Entity\Order\OrderItem $orderItem null;
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getPack(): ?Pack
  42.     {
  43.         return $this->pack;
  44.     }
  45.     public function setPack(?Pack $pack): self
  46.     {
  47.         $this->pack $pack;
  48.         return $this;
  49.     }
  50.     public function getCustomer(): ?Customer
  51.     {
  52.         return $this->customer;
  53.     }
  54.     public function setCustomer(?Customer $customer): self
  55.     {
  56.         $this->customer $customer;
  57.         return $this;
  58.     }
  59.     public function getStartAt(): ?\DateTimeInterface
  60.     {
  61.         return $this->startAt;
  62.     }
  63.     public function setStartAt(\DateTimeInterface $startAt): self
  64.     {
  65.         $this->startAt $startAt;
  66.         return $this;
  67.     }
  68.     public function getEndAt(): ?\DateTimeInterface
  69.     {
  70.         return $this->endAt;
  71.     }
  72.     public function setEndAt(\DateTimeInterface $endAt): self
  73.     {
  74.         $this->endAt $endAt;
  75.         return $this;
  76.     }
  77.     public function getOrderItem(): ?OrderItem
  78.     {
  79.         return $this->orderItem;
  80.     }
  81.     public function setOrderItem(?OrderItem $orderItem): self
  82.     {
  83.         // unset the owning side of the relation if necessary
  84.         if ($orderItem === null && $this->orderItem !== null) {
  85.             $this->orderItem->setPackEngagement(null);
  86.         }
  87.         // set the owning side of the relation if necessary
  88.         if ($orderItem !== null && $orderItem->getPackEngagement() !== $this) {
  89.             $orderItem->setPackEngagement($this);
  90.         }
  91.         $this->orderItem $orderItem;
  92.         return $this;
  93.     }
  94.     #[Groups(['read','write'])]
  95.     public function getOrderNumber(){
  96.         return $this->getOrderItem()->getParentOrder()->getOrderNumber();
  97.     }
  98.     #[Groups(['read','write'])]
  99.     public function getOrderId(){
  100.         return $this->getOrderItem()->getParentOrder()->getId();
  101.     }
  102.     #[Groups(['read','write'])]
  103.     public function getProduct(){
  104.         return $this->getOrderItem()->getProduct();
  105.     }
  106. }