src/Entity/Catalog/GiftCode.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Catalog;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Catalog\GiftCodeRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Serializer\Annotation\SerializedName;
  8. /**
  9.  * @ORM\Entity(repositoryClass=GiftCodeRepository::class)
  10.  * @ApiResource(
  11.  *     attributes={
  12.  *          "normalization_context"={
  13.  *              "groups"={
  14.  *                  "GiftCode:output",
  15.  *                  "GiftCode:io",
  16.  *              },
  17.  *          },
  18.  *          "denormalization_context"={
  19.  *              "groups"={
  20.  *                  "GiftCode:input",
  21.  *                  "GiftCode:io",
  22.  *              },
  23.  *          }
  24.  *      },
  25.  *     collectionOperations={
  26.  *          "get"
  27.  *     },
  28.  *     itemOperations={
  29.  *          "get"
  30.  *     }
  31.  * )
  32.  */
  33. class GiftCode
  34. {
  35.     public const PARAMS_USED_YES 'yes';
  36.     public const PARAMS_USED_NO 'no';
  37.     public const MAIL_CONTENT_VARIABLE_CODE '%CODE%';
  38.     /**
  39.      * @ORM\Id
  40.      * @ORM\GeneratedValue
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private ?int $id;
  44.     /**
  45.      * @ORM\Column(type="string", length=255)
  46.      * @Groups({
  47.      *     "Gift:output",
  48.      *     "get_user_gift_carts",
  49.      *     "get_order_by_user",
  50.      *     "Order:output",
  51.      * })
  52.      */
  53.     private string $code;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=Gift::class)
  56.      * @ORM\JoinColumn(name="gift_id")
  57.      * @SerializedName("gift")
  58.      */
  59.     private Gift $gift;
  60.     /**
  61.      * @ORM\ManyToOne(targetEntity=Order::class, inversedBy="giftCodes")
  62.      * @ORM\JoinColumn(name="order_id", nullable=true)
  63.      * @SerializedName("order")
  64.      */
  65.     private ?Order $order;
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getCode(): string
  71.     {
  72.         return $this->code;
  73.     }
  74.     public function setCode(string $code): self
  75.     {
  76.         $this->code $code;
  77.         return $this;
  78.     }
  79.     public function getGift(): Gift
  80.     {
  81.         return $this->gift;
  82.     }
  83.     public function setGift(Gift $gift): self
  84.     {
  85.         $this->gift $gift;
  86.         return $this;
  87.     }
  88.     public function getOrder(): ?Order
  89.     {
  90.         return $this->order;
  91.     }
  92.     public function setOrder(Order $order): self
  93.     {
  94.         $this->order $order;
  95.         return $this;
  96.     }
  97. }