src/Flexy/ShopBundle/Entity/Customer/PackEngagement.php line 19
<?php
namespace App\Flexy\ShopBundle\Entity\Customer;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Flexy\ShopBundle\Entity\Order\OrderItem;
use App\Flexy\ShopBundle\Repository\Customer\PackEngagementRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(SearchFilter::class, properties: ['customer'=>'exact'])]
#[ORM\Entity(repositoryClass: PackEngagementRepository::class)]
class PackEngagement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['read','write'])]
private $id;
#[ORM\ManyToOne(targetEntity: Pack::class, inversedBy: 'packEngagements', cascade: ['persist'])]
private ?\App\Flexy\ShopBundle\Entity\Customer\Pack $pack = null;
#[ORM\ManyToOne(targetEntity: Customer::class, inversedBy: 'packEngagements')]
private ?\App\Flexy\ShopBundle\Entity\Customer\Customer $customer = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'datetime')]
private ?\DateTimeInterface $startAt = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'datetime')]
private ?\DateTimeInterface $endAt = null;
#[ORM\OneToOne(targetEntity: OrderItem::class, mappedBy: 'packEngagement', cascade: ['persist', 'remove'])]
private ?\App\Flexy\ShopBundle\Entity\Order\OrderItem $orderItem = null;
public function getId(): ?int
{
return $this->id;
}
public function getPack(): ?Pack
{
return $this->pack;
}
public function setPack(?Pack $pack): self
{
$this->pack = $pack;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function getStartAt(): ?\DateTimeInterface
{
return $this->startAt;
}
public function setStartAt(\DateTimeInterface $startAt): self
{
$this->startAt = $startAt;
return $this;
}
public function getEndAt(): ?\DateTimeInterface
{
return $this->endAt;
}
public function setEndAt(\DateTimeInterface $endAt): self
{
$this->endAt = $endAt;
return $this;
}
public function getOrderItem(): ?OrderItem
{
return $this->orderItem;
}
public function setOrderItem(?OrderItem $orderItem): self
{
// unset the owning side of the relation if necessary
if ($orderItem === null && $this->orderItem !== null) {
$this->orderItem->setPackEngagement(null);
}
// set the owning side of the relation if necessary
if ($orderItem !== null && $orderItem->getPackEngagement() !== $this) {
$orderItem->setPackEngagement($this);
}
$this->orderItem = $orderItem;
return $this;
}
#[Groups(['read','write'])]
public function getOrderNumber(){
return $this->getOrderItem()->getParentOrder()->getOrderNumber();
}
#[Groups(['read','write'])]
public function getOrderId(){
return $this->getOrderItem()->getParentOrder()->getId();
}
#[Groups(['read','write'])]
public function getProduct(){
return $this->getOrderItem()->getProduct();
}
}