<?php
namespace App\Entity;
use App\Repository\ProductClassRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Product;
use App\Entity\ProductStock;
use App\Entity\TaxRule;
use App\Entity\SaleType;
use App\Entity\ClassCategory;
use App\Entity\DeliveryDuration;
use App\Entity\Member;
#[ORM\Entity(repositoryClass: ProductClassRepository::class)]
#[ORM\Table(name: "dtb_product_class")]
#[ORM\HasLifecycleCallbacks]
class ProductClass
{
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column]
// private ?int $id = null;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
#[ORM\Column(type: "integer", options: ["unsigned" => true])]
private ?int $id = null;
/**
* @var Product
* Many-to-One リレーション:`Product` エンティティと結びつける。
* `product_id` を参照し、`Product` エンティティの `id` カラムと結合。
*/
#[ORM\ManyToOne(targetEntity: Product::class, inversedBy: "productClasses")]
#[ORM\JoinColumn(name: "product_id", referencedColumnName: "id", nullable: false)]
private ?Product $Product = null;
/**
* @var SaleType|null
* Many-to-One リレーション:`SaleType` エンティティと結びつける。
*/
#[ORM\ManyToOne(targetEntity: SaleType::class)]
#[ORM\JoinColumn(name: "sale_type_id", referencedColumnName: "id")]
private ?SaleType $saleType = null;
/**
* @var ClassCategory|null
* class_category_id1に対応するClassCategoryとのManyToOneリレーション
*/
#[ORM\ManyToOne(targetEntity: ClassCategory::class)]
#[ORM\JoinColumn(name: "class_category_id1", referencedColumnName: "id", nullable: true)]
private ?ClassCategory $classCategory1 = null;
/**
* @var ClassCategory|null
* class_category_id2に対応するClassCategoryとのManyToOneリレーション
*/
#[ORM\ManyToOne(targetEntity: ClassCategory::class)]
#[ORM\JoinColumn(name: "class_category_id2", referencedColumnName: "id", nullable: true)]
private ?ClassCategory $classCategory2 = null;
/**
* @var DeliveryDuration|null
* delivery_duration_idに対応するDeliveryDurationとのManyToOneリレーション
*/
#[ORM\ManyToOne(targetEntity: DeliveryDuration::class)]
#[ORM\JoinColumn(name: "delivery_duration_id", referencedColumnName: "id", nullable: true)]
private ?DeliveryDuration $deliveryDuration = null;
/**
* @var Member|null
* `creator_id`に対応する`Member`エンティティとのManyToOneリレーション
*/
#[ORM\ManyToOne(targetEntity: Member::class)]
#[ORM\JoinColumn(name: "creator_id", referencedColumnName: "id", nullable: true)]
private ?Member $creator = null;
/**
* @var string|null
* EC-CUBEの`code`フィールドに対応する商品コード
*/
#[ORM\Column(name: "product_code", type: "string", length: 255, nullable: true)]
private ?string $code = null;
/**
* @var string|null
* 在庫数を表すプロパティ
*/
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: '0', nullable: true)]
private ?string $stock = null;
/**
* @var bool 在庫が無制限かどうか
* デフォルト値は`false`
*/
#[ORM\Column(name: "stock_unlimited", type: "boolean", options: ["default" => false])]
private bool $stock_unlimited = false;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: '0', nullable: true)]
private ?string $sale_limit = null;
#[ORM\Column(type: Types::DECIMAL, precision: 12, scale: 2, nullable: true)]
private ?string $price01 = null;
#[ORM\Column(type: Types::DECIMAL, precision: 12, scale: 2)]
private ?string $price02 = null;
#[ORM\Column(type: Types::DECIMAL, precision: 12, scale: 2, nullable: true)]
private ?string $delivery_fee = null;
#[ORM\Column]
private ?int $visible = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $create_date = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $update_date = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $currency_code = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: '0', nullable: true)]
private ?string $point_rate = null;
#[ORM\Column(length: 255)]
private ?string $discriminator_type = 'productclass';
public function getId(): ?int
{
return $this->id;
}
public function getProduct(): ?Product
{
return $this->Product;
}
public function setProduct(?Product $product): self
{
$this->Product = $product;
return $this;
}
/**
* SaleTypeエンティティを取得する
*
* @return SaleType|null SaleTypeエンティティ、またはnull
*/
public function getSaleType(): ?SaleType
{
return $this->saleType;
}
/**
* SaleTypeエンティティを設定する
*
* @param SaleType|null $saleType 設定するSaleTypeエンティティ
* @return self
*/
public function setSaleType(?SaleType $saleType): self
{
$this->saleType = $saleType;
return $this;
}
public function getClassCategory1(): ?ClassCategory
{
return $this->classCategory1;
}
public function setClassCategory1(?ClassCategory $classCategory1): self
{
$this->classCategory1 = $classCategory1;
return $this;
}
public function getClassCategory2(): ?ClassCategory
{
return $this->classCategory2;
}
public function setClassCategory2(?ClassCategory $classCategory2): self
{
$this->classCategory2 = $classCategory2;
return $this;
}
/**
* Set DeliveryDurationエンティティを設定する
*
* @param DeliveryDuration|null $deliveryDuration
* @return $this
*/
public function setDeliveryDuration(?DeliveryDuration $deliveryDuration): self
{
$this->deliveryDuration = $deliveryDuration;
return $this;
}
/**
* Get DeliveryDurationエンティティを取得する
*
* @return DeliveryDuration|null
*/
public function getDeliveryDuration(): ?DeliveryDuration
{
return $this->deliveryDuration;
}
/**
* Set creator.
*
* @param Member|null $creator
* @return $this
*/
public function setCreator(?Member $creator): self
{
$this->creator = $creator;
return $this;
}
/**
* Get creator.
*
* @return Member|null
*/
public function getCreator(): ?Member
{
return $this->creator;
}
/**
* クローンを作成する際にIDをリセット
*/
public function __clone()
{
$this->id = null;
}
/**
* 商品コードを取得
*
* @return string|null 商品コード
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* 商品コードを設定
*
* @param string|null $code 商品コード
* @return self
*/
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
/**
* 在庫数を取得
*
* @return string|null 在庫数
*/
public function getStock(): ?string
{
return $this->stock;
}
/**
* 在庫数を設定
*
* @param string|null $stock 在庫数
* @return self
*/
public function setStock(?string $stock): self
{
$this->stock = $stock;
return $this;
}
/**
* 在庫無制限フラグを取得
*
* @return bool 在庫無制限フラグ
*/
public function isStockUnlimited(): bool
{
return $this->stock_unlimited;
}
/**
* 在庫無制限フラグを設定
*
* @param bool $stock_unlimited 在庫無制限フラグ
* @return self
*/
public function setStockUnlimited(bool $stock_unlimited): self
{
$this->stock_unlimited = $stock_unlimited;
return $this;
}
public function getSaleLimit(): ?string
{
return $this->sale_limit;
}
public function setSaleLimit(?string $sale_limit): static
{
$this->sale_limit = $sale_limit;
return $this;
}
// 販売価格
public function getPrice01(): ?string
{
return $this->price01;
}
public function setPrice01(?string $price01): static
{
$this->price01 = $price01;
return $this;
}
// 通常価格
public function getPrice02(): ?string
{
return $this->price02;
}
public function setPrice02(string $price02): static
{
$this->price02 = $price02;
return $this;
}
public function getDeliveryFee(): ?string
{
return $this->delivery_fee;
}
public function setDeliveryFee(?string $delivery_fee): static
{
$this->delivery_fee = $delivery_fee;
return $this;
}
public function getVisible(): ?int
{
return $this->visible;
}
public function setVisible(int $visible): static
{
$this->visible = $visible;
return $this;
}
public function getCreateDate(): ?\DateTimeInterface
{
return $this->create_date;
}
public function setCreateDate(\DateTimeInterface $create_date): static
{
$this->create_date = $create_date;
return $this;
}
public function getUpdateDate(): ?\DateTimeInterface
{
return $this->update_date;
}
public function setUpdateDate(\DateTimeInterface $update_date): static
{
$this->update_date = $update_date;
return $this;
}
public function getCurrencyCode(): ?string
{
return $this->currency_code;
}
public function setCurrencyCode(?string $currency_code): static
{
$this->currency_code = $currency_code;
return $this;
}
public function getPointRate(): ?string
{
return $this->point_rate;
}
public function setPointRate(?string $point_rate): static
{
$this->point_rate = $point_rate;
return $this;
}
public function getDiscriminatorType(): ?string
{
return $this->discriminator_type;
}
public function setDiscriminatorType(string $discriminator_type): static
{
$this->discriminator_type = $discriminator_type;
return $this;
}
/**
* エンティティの初回保存時に create_date と update_date を自動設定
*/
#[ORM\PrePersist]
public function onPrePersist(): void
{
$this->create_date = new \DateTime();
$this->update_date = new \DateTime();
}
/**
* エンティティの更新時に update_date のみを自動設定
*/
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$this->update_date = new \DateTime();
}
}