<?php
namespace App\Entity\Catalog;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Catalog\GiftCodeRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
/**
* @ORM\Entity(repositoryClass=GiftCodeRepository::class)
* @ApiResource(
* attributes={
* "normalization_context"={
* "groups"={
* "GiftCode:output",
* "GiftCode:io",
* },
* },
* "denormalization_context"={
* "groups"={
* "GiftCode:input",
* "GiftCode:io",
* },
* }
* },
* collectionOperations={
* "get"
* },
* itemOperations={
* "get"
* }
* )
*/
class GiftCode
{
public const PARAMS_USED_YES = 'yes';
public const PARAMS_USED_NO = 'no';
public const MAIL_CONTENT_VARIABLE_CODE = '%CODE%';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "Gift:output",
* "get_user_gift_carts",
* "get_order_by_user",
* "Order:output",
* })
*/
private string $code;
/**
* @ORM\ManyToOne(targetEntity=Gift::class)
* @ORM\JoinColumn(name="gift_id")
* @SerializedName("gift")
*/
private Gift $gift;
/**
* @ORM\ManyToOne(targetEntity=Order::class, inversedBy="giftCodes")
* @ORM\JoinColumn(name="order_id", nullable=true)
* @SerializedName("order")
*/
private ?Order $order;
public function getId(): ?int
{
return $this->id;
}
public function getCode(): string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getGift(): Gift
{
return $this->gift;
}
public function setGift(Gift $gift): self
{
$this->gift = $gift;
return $this;
}
public function getOrder(): ?Order
{
return $this->order;
}
public function setOrder(Order $order): self
{
$this->order = $order;
return $this;
}
}