src/Entity/ProductClass.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductClassRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Product;
  7. use App\Entity\ProductStock;
  8. use App\Entity\TaxRule;
  9. use App\Entity\SaleType;
  10. use App\Entity\ClassCategory;
  11. use App\Entity\DeliveryDuration;
  12. use App\Entity\Member;
  13. #[ORM\Entity(repositoryClassProductClassRepository::class)]
  14. #[ORM\Table(name"dtb_product_class")]
  15. #[ORM\HasLifecycleCallbacks]
  16. class ProductClass
  17. {
  18.     // #[ORM\Id]
  19.     // #[ORM\GeneratedValue]
  20.     // #[ORM\Column]
  21.     // private ?int $id = null;
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue(strategy"IDENTITY")]
  24.     #[ORM\Column(type"integer"options: ["unsigned" => true])]
  25.     private ?int $id null;
  26.     /**
  27.      * @var Product
  28.      * Many-to-One リレーション:`Product` エンティティと結びつける。
  29.      * `product_id` を参照し、`Product` エンティティの `id` カラムと結合。
  30.      */
  31.     #[ORM\ManyToOne(targetEntityProduct::class, inversedBy"productClasses")]
  32.     #[ORM\JoinColumn(name"product_id"referencedColumnName"id"nullablefalse)]
  33.     private ?Product $Product null;
  34.     /**
  35.      * @var SaleType|null
  36.      * Many-to-One リレーション:`SaleType` エンティティと結びつける。
  37.      */
  38.     #[ORM\ManyToOne(targetEntitySaleType::class)]
  39.     #[ORM\JoinColumn(name"sale_type_id"referencedColumnName"id")]
  40.     private ?SaleType $saleType null;
  41.     /**
  42.      * @var ClassCategory|null
  43.      * class_category_id1に対応するClassCategoryとのManyToOneリレーション
  44.      */
  45.     #[ORM\ManyToOne(targetEntityClassCategory::class)]
  46.     #[ORM\JoinColumn(name"class_category_id1"referencedColumnName"id"nullabletrue)]
  47.     private ?ClassCategory $classCategory1 null;
  48.     /**
  49.      * @var ClassCategory|null
  50.      * class_category_id2に対応するClassCategoryとのManyToOneリレーション
  51.      */
  52.     #[ORM\ManyToOne(targetEntityClassCategory::class)]
  53.     #[ORM\JoinColumn(name"class_category_id2"referencedColumnName"id"nullabletrue)]
  54.     private ?ClassCategory $classCategory2 null;
  55.     /**
  56.      * @var DeliveryDuration|null
  57.      * delivery_duration_idに対応するDeliveryDurationとのManyToOneリレーション
  58.      */
  59.     #[ORM\ManyToOne(targetEntityDeliveryDuration::class)]
  60.     #[ORM\JoinColumn(name"delivery_duration_id"referencedColumnName"id"nullabletrue)]
  61.     private ?DeliveryDuration $deliveryDuration null;
  62.     /**
  63.      * @var Member|null
  64.      * `creator_id`に対応する`Member`エンティティとのManyToOneリレーション
  65.      */
  66.     #[ORM\ManyToOne(targetEntityMember::class)]
  67.     #[ORM\JoinColumn(name"creator_id"referencedColumnName"id"nullabletrue)]
  68.     private ?Member $creator null;
  69.     /**
  70.      * @var string|null
  71.      * EC-CUBEの`code`フィールドに対応する商品コード
  72.      */
  73.     #[ORM\Column(name"product_code"type"string"length255nullabletrue)]
  74.     private ?string $code null;
  75.     /**
  76.      * @var string|null
  77.      * 在庫数を表すプロパティ
  78.      */
  79.     #[ORM\Column(typeTypes::DECIMALprecision10scale'0'nullabletrue)]
  80.     private ?string $stock null;
  81.     /**
  82.      * @var bool 在庫が無制限かどうか
  83.      * デフォルト値は`false`
  84.      */
  85.     #[ORM\Column(name"stock_unlimited"type"boolean"options: ["default" => false])]
  86.     private bool $stock_unlimited false;
  87.     #[ORM\Column(typeTypes::DECIMALprecision10scale'0'nullabletrue)]
  88.     private ?string $sale_limit null;
  89.     #[ORM\Column(typeTypes::DECIMALprecision12scale2nullabletrue)]
  90.     private ?string $price01 null;
  91.     #[ORM\Column(typeTypes::DECIMALprecision12scale2)]
  92.     private ?string $price02 null;
  93.     #[ORM\Column(typeTypes::DECIMALprecision12scale2nullabletrue)]
  94.     private ?string $delivery_fee null;
  95.     #[ORM\Column]
  96.     private ?int $visible null;
  97.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  98.     private ?\DateTimeInterface $create_date null;
  99.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  100.     private ?\DateTimeInterface $update_date null;
  101.     #[ORM\Column(length255nullabletrue)]
  102.     private ?string $currency_code null;
  103.     #[ORM\Column(typeTypes::DECIMALprecision10scale'0'nullabletrue)]
  104.     private ?string $point_rate null;
  105.     #[ORM\Column(length255)]
  106.     private ?string $discriminator_type 'productclass';
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getProduct(): ?Product
  112.     {
  113.         return $this->Product;
  114.     }
  115.     public function setProduct(?Product $product): self
  116.     {
  117.         $this->Product $product;
  118.         return $this;
  119.     }
  120.     /**
  121.      * SaleTypeエンティティを取得する
  122.      *
  123.      * @return SaleType|null SaleTypeエンティティ、またはnull
  124.      */
  125.     public function getSaleType(): ?SaleType
  126.     {
  127.         return $this->saleType;
  128.     }
  129.     /**
  130.      * SaleTypeエンティティを設定する
  131.      *
  132.      * @param SaleType|null $saleType 設定するSaleTypeエンティティ
  133.      * @return self
  134.      */
  135.     public function setSaleType(?SaleType $saleType): self
  136.     {
  137.         $this->saleType $saleType;
  138.         return $this;
  139.     }
  140.     public function getClassCategory1(): ?ClassCategory
  141.     {
  142.         return $this->classCategory1;
  143.     }
  144.     public function setClassCategory1(?ClassCategory $classCategory1): self
  145.     {
  146.         $this->classCategory1 $classCategory1;
  147.         return $this;
  148.     }
  149.     public function getClassCategory2(): ?ClassCategory
  150.     {
  151.         return $this->classCategory2;
  152.     }
  153.     public function setClassCategory2(?ClassCategory $classCategory2): self
  154.     {
  155.         $this->classCategory2 $classCategory2;
  156.         return $this;
  157.     }
  158.     /**
  159.      * Set DeliveryDurationエンティティを設定する
  160.      *
  161.      * @param DeliveryDuration|null $deliveryDuration
  162.      * @return $this
  163.      */
  164.     public function setDeliveryDuration(?DeliveryDuration $deliveryDuration): self
  165.     {
  166.         $this->deliveryDuration $deliveryDuration;
  167.         return $this;
  168.     }
  169.     /**
  170.      * Get DeliveryDurationエンティティを取得する
  171.      *
  172.      * @return DeliveryDuration|null
  173.      */
  174.     public function getDeliveryDuration(): ?DeliveryDuration
  175.     {
  176.         return $this->deliveryDuration;
  177.     }
  178.     /**
  179.      * Set creator.
  180.      *
  181.      * @param Member|null $creator
  182.      * @return $this
  183.      */
  184.     public function setCreator(?Member $creator): self
  185.     {
  186.         $this->creator $creator;
  187.         return $this;
  188.     }
  189.     /**
  190.      * Get creator.
  191.      *
  192.      * @return Member|null
  193.      */
  194.     public function getCreator(): ?Member
  195.     {
  196.         return $this->creator;
  197.     }
  198.     /**
  199.      * クローンを作成する際にIDをリセット
  200.      */
  201.     public function __clone()
  202.     {
  203.         $this->id null;
  204.     }
  205.     /**
  206.      * 商品コードを取得
  207.      *
  208.      * @return string|null 商品コード
  209.      */
  210.     public function getCode(): ?string
  211.     {
  212.         return $this->code;
  213.     }
  214.     /**
  215.      * 商品コードを設定
  216.      *
  217.      * @param string|null $code 商品コード
  218.      * @return self
  219.      */
  220.     public function setCode(?string $code): self
  221.     {
  222.         $this->code $code;
  223.         return $this;
  224.     }
  225.     /**
  226.      * 在庫数を取得
  227.      *
  228.      * @return string|null 在庫数
  229.      */
  230.     public function getStock(): ?string
  231.     {
  232.         return $this->stock;
  233.     }
  234.     /**
  235.      * 在庫数を設定
  236.      *
  237.      * @param string|null $stock 在庫数
  238.      * @return self
  239.      */
  240.     public function setStock(?string $stock): self
  241.     {
  242.         $this->stock $stock;
  243.         return $this;
  244.     }
  245.     /**
  246.      * 在庫無制限フラグを取得
  247.      *
  248.      * @return bool 在庫無制限フラグ
  249.      */
  250.     public function isStockUnlimited(): bool
  251.     {
  252.         return $this->stock_unlimited;
  253.     }
  254.     /**
  255.      * 在庫無制限フラグを設定
  256.      *
  257.      * @param bool $stock_unlimited 在庫無制限フラグ
  258.      * @return self
  259.      */
  260.     public function setStockUnlimited(bool $stock_unlimited): self
  261.     {
  262.         $this->stock_unlimited $stock_unlimited;
  263.         return $this;
  264.     }
  265.     public function getSaleLimit(): ?string
  266.     {
  267.         return $this->sale_limit;
  268.     }
  269.     public function setSaleLimit(?string $sale_limit): static
  270.     {
  271.         $this->sale_limit $sale_limit;
  272.         return $this;
  273.     }
  274.     // 販売価格
  275.     public function getPrice01(): ?string
  276.     {
  277.         return $this->price01;
  278.     }
  279.     public function setPrice01(?string $price01): static
  280.     {
  281.         $this->price01 $price01;
  282.         return $this;
  283.     }
  284.     // 通常価格
  285.     public function getPrice02(): ?string
  286.     {
  287.         return $this->price02;
  288.     }
  289.     public function setPrice02(string $price02): static
  290.     {
  291.         $this->price02 $price02;
  292.         return $this;
  293.     }
  294.     public function getDeliveryFee(): ?string
  295.     {
  296.         return $this->delivery_fee;
  297.     }
  298.     public function setDeliveryFee(?string $delivery_fee): static
  299.     {
  300.         $this->delivery_fee $delivery_fee;
  301.         return $this;
  302.     }
  303.     public function getVisible(): ?int
  304.     {
  305.         return $this->visible;
  306.     }
  307.     public function setVisible(int $visible): static
  308.     {
  309.         $this->visible $visible;
  310.         return $this;
  311.     }
  312.     public function getCreateDate(): ?\DateTimeInterface
  313.     {
  314.         return $this->create_date;
  315.     }
  316.     public function setCreateDate(\DateTimeInterface $create_date): static
  317.     {
  318.         $this->create_date $create_date;
  319.         return $this;
  320.     }
  321.     public function getUpdateDate(): ?\DateTimeInterface
  322.     {
  323.         return $this->update_date;
  324.     }
  325.     public function setUpdateDate(\DateTimeInterface $update_date): static
  326.     {
  327.         $this->update_date $update_date;
  328.         return $this;
  329.     }
  330.     public function getCurrencyCode(): ?string
  331.     {
  332.         return $this->currency_code;
  333.     }
  334.     public function setCurrencyCode(?string $currency_code): static
  335.     {
  336.         $this->currency_code $currency_code;
  337.         return $this;
  338.     }
  339.     public function getPointRate(): ?string
  340.     {
  341.         return $this->point_rate;
  342.     }
  343.     public function setPointRate(?string $point_rate): static
  344.     {
  345.         $this->point_rate $point_rate;
  346.         return $this;
  347.     }
  348.     public function getDiscriminatorType(): ?string
  349.     {
  350.         return $this->discriminator_type;
  351.     }
  352.     public function setDiscriminatorType(string $discriminator_type): static
  353.     {
  354.         $this->discriminator_type $discriminator_type;
  355.         return $this;
  356.     }
  357.     /**
  358.      * エンティティの初回保存時に create_date と update_date を自動設定
  359.      */
  360.     #[ORM\PrePersist]
  361.     public function onPrePersist(): void
  362.     {
  363.         $this->create_date = new \DateTime();
  364.         $this->update_date = new \DateTime();
  365.     }
  366.     /**
  367.      * エンティティの更新時に update_date のみを自動設定
  368.      */
  369.     #[ORM\PreUpdate]
  370.     public function onPreUpdate(): void
  371.     {
  372.         $this->update_date = new \DateTime();
  373.     }
  374. }