<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\ProductsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\SecurityInterface;
use DateTimeImmutable;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Post;
use App\Controller\BatchCreateProductAction;
use App\Controller\ProductController;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Annotation\ApiProperty;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use App\Filter\ShowProductsFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
use App\Filter\CustomOrFilter;
#[ORM\Entity(repositoryClass: ProductsRepository::class)]
#[ApiResource(
operations: [
new Get(),
new Post(),
new Delete(),
new GetCollection(),
new Put(),
new Post(
name: 'batch',
uriTemplate: '/products/batch',
controller: BatchCreateProductAction::class
),
new Get(
name: 'filter_product',
uriTemplate: '/products/filter',
controller: ProductController::class
)
],
normalizationContext: ['groups' => ['product:read']],
denormalizationContext: ['groups' => ['product:write']],
order: ['id' => 'DESC'],
// paginationPartial: true,
paginationEnabled: true,
// filters: [ShowProductsFilter::class]
)]
// #[Get]
#[ORM\HasLifecycleCallbacks]
#[ApiFilter(RangeFilter::class, properties: ['balance'])]
// #[ApiFilter(CustomOrFilter::class,properties: [
// 'name' => 'ipartial',
// 'barcode' => 'exact',
// 'article' => 'exact',
// 'code1c' => 'exact',
// ])]
#[ApiFilter(
SearchFilter::class,
properties: [
'id' => 'exact',
'oldCode' => 'exact',
// 'code1c' => 'exact',
'top' => 'exact',
'productToOrder' => 'exact',
'name' => 'ipartial',
// 'barcode' => 'exact',
'category.id' => 'exact',
'attributeItems.id' => 'exact',
'show' => 'exact',
'article' => 'exact',
'prices.product' => 'exact',
'prices.agreement.virtual' => 'exact',
'prices.agreement.account.id' => 'exact',
'productBalanceInStorages.manager.id' => 'exact',
'orderProducts.order.account.id' => 'exact',
'orderProducts.order.account.user.id' => 'exact',
],
)]
#[ApiFilter(OrderFilter::class, properties: ['price', 'name'], arguments: ['orderParameterName' => 'order'])]
// #[ApiFilter(ShowProductsFilter::class)]
// #[ApiFilter(ShowProductsFilter::class)]
class Products
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['product:read', 'product:write', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', 'product_storage_balance:read', 'price:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['product:read', 'product:write', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', 'product_storage_balance:read', 'price:read'])]
private ?string $name = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[Groups(['product:read'])]
private ?\DateTimeInterface $date_entered;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
#[Groups(['product:read'])]
private ?\DateTimeInterface $date_modified;
#[ORM\ManyToOne(inversedBy: 'products')]
#[Groups(['product:read'])]
#[MaxDepth(1)]
private ?User $modified_user = null;
#[ORM\ManyToOne(inversedBy: 'create_products')]
#[Groups(['product:read'])]
#[MaxDepth(1)]
private ?User $created_by;
#[Groups(['product:read', 'product:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(length: 20, nullable: true)]
#[Groups(['product:read', 'product:write', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order_product:read', 'product_storage_balance:read'])]
private ?string $code1c = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['product:read', 'product:write', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'product_storage_balance:read', 'price:read'])]
private ?string $barcode = null;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?string $status = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write', 'order_product:read', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'attributes_items:read', 'attributes:read', 'product_storage_balance:read', 'price:read'])]
private ?float $price = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write', 'order_product:read'])]
private ?float $priceIncome = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $mark_up = null;
#[ORM\Column]
#[Groups(['product:read', 'product:write'])]
private ?float $min_mark_up = 1;
#[ORM\Column(length: 100, nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?string $packing_type = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $packing_type_count = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write', 'order_product:read'])]
private ?int $discounts = null;
#[ORM\Column]
#[Groups(['product:read', 'product:write'])]
private ?int $top = 0;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?int $count_order = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?int $productToOrder = null;
#[ORM\ManyToOne]
#[Groups(['product:read', 'product:write', 'load_invoice:read', 'pre_order_product:read', 'pre_order:read', 'order:read', 'order_product:read', 'order_product:read', 'product_storage_balance:read'])]
#[ApiProperty(writable: true)]
#[MaxDepth(1)]
private ?MeasurmentUnit $measurement_unit = null;
#[Groups(['product:read', 'product:write'])]
#[MaxDepth(1)]
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductInfo::class,)]
private ?Collection $productInfos = null;
#[MaxDepth(1)]
#[Groups(['product:read', 'product:write', 'user_like:read', 'pre_order_product:read', 'pre_order:read', 'order:read', 'order_product:read', 'order_product:read'])]
#[ORM\OneToMany(mappedBy: 'product', targetEntity: MediaObject::class)]
private Collection $media;
#[MaxDepth(2)]
#[Groups(['product:read', 'product:write'])]
#[ORM\OneToMany(mappedBy: 'product', targetEntity: IncomingInvoiceProduct::class)]
private Collection $incomingInvoiceProducts;
private ?SecurityInterface $security = null;
#[ORM\Column(length: 20, nullable: true)]
#[Groups(['product:read', 'product:write', 'load_invoice:read', 'pre_order_product:read', 'pre_order:read', 'order:read', 'order_product:read', 'order_product:read', 'product_storage_balance:read'])]
private ?string $article = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $nds = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?bool $service = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?bool $transport_service = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?bool $exise = false;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?bool $expiration_date = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $unit_volume = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $net_weight = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $gross_weight = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?bool $go_by_weight = null;
#[ORM\Column(nullable: true)]
#[Groups(['product:read', 'product:write'])]
private ?float $packaging = null;
#[ORM\ManyToOne(inversedBy: 'products')]
#[MaxDepth(2)]
#[Groups(['product:read', 'product:write'])]
private ?SiteProducts $site_product = null;
#[Groups(['product:read', 'product:write', 'attributes:read'])]
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'products')]
#[MaxDepth(1)]
private Collection $category;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: MediaObject::class)]
private Collection $mediaObjects;
#[Groups(['product:read', 'product:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $oldCode = null;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: UserLikeList::class)]
private Collection $userLikeLists;
#[Groups(['product:read', 'product:write'])]
#[ORM\ManyToMany(targetEntity: AttributeItems::class, mappedBy: 'product')]
private Collection $attributeItems;
#[Groups(['product:read', 'product:write', 'load_invoice:read', 'pre_order_product:read', 'pre_order:read', 'order:read', 'order_product:read', 'order_product:read'])]
#[ORM\Column(nullable: true)]
private ?bool $show = null;
#[Groups(['product:read', 'product:write', 'load_invoice:read', 'pre_order_product:read', 'pre_order:read', 'order:read', 'order_product:read', 'order_product:read'])]
#[ORM\ManyToOne(inversedBy: 'products')]
private ?Storage $storage = null;
#[MaxDepth(2)]
#[Groups(['product:read', 'product:write','order:read', 'order_product:read'])]
#[ORM\ManyToOne(inversedBy: 'products')]
private ?StorageElement $storageElement = null;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: Prices::class)]
private Collection $prices;
#[Groups(['product:read', 'product:write', 'order_product:read', 'pre_order_product:read'])]
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductBalanceInStorage::class)]
private Collection $productBalanceInStorages;
#[Groups(['product:read', 'product:write', 'order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'user_like:read', 'order_product:read', 'attributes_items:read', 'attributes:read', ])]
#[ORM\Column(nullable: true)]
private ?float $balance = null;
#[ApiProperty(writable: true)]
#[ORM\OneToMany(mappedBy: 'product', targetEntity: OrderProduct::class)]
private Collection $orderProducts;
public function __construct() {
$this->productInfos = new ArrayCollection();
$this->media = new ArrayCollection();
$this->incomingInvoiceProducts = new ArrayCollection();
$this->category = new ArrayCollection();
$this->mediaObjects = new ArrayCollection();
$this->userLikeLists = new ArrayCollection();
$this->attributeItems = new ArrayCollection();
$this->prices = new ArrayCollection();
$this->productBalanceInStorages = new ArrayCollection();
$this->orderProducts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): self
{
$this->id = $id;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->date_entered;
}
// public function setDateEntered(?\DateTimeInterface $date_entered): self
// {
// $this->date_entered = $date_entered;
// return $this;
// }
public function getDateModified(): ?\DateTimeInterface
{
return $this->date_modified;
}
// public function setDateModified(?\DateTimeInterface $date_modified): self
// {
// $this->date_modified = $date_modified;
// return $this;
// }
public function getModifiedUser(): ?User
{
return $this->modified_user;
}
// public function setModifiedUserId(?User $modified_user_id): self
// {
// $this->modified_user_id = $modified_user_id;
// return $this;
// }
public function getCreatedBy(): ?User
{
return $this->created_by;
}
public function setCreatedBy(?User $created_by): self
{
$this->created_by = $created_by;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCode1c(): ?string
{
return $this->code1c;
}
public function setCode1c(?string $code1c): self
{
$this->code1c = $code1c;
return $this;
}
public function getBarcode(): ?string
{
return $this->barcode;
}
public function setBarcode(?string $barcode): self
{
$this->barcode = $barcode;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
public function getPriceIncome(): ?float
{
return $this->priceIncome;
}
public function setPriceIncome(?float $priceIncome): self
{
$this->priceIncome = $priceIncome;
return $this;
}
public function getMarkUp(): ?float
{
return $this->mark_up;
}
public function setMarkUp(?float $mark_up): self
{
$this->mark_up = $mark_up;
return $this;
}
public function getMinMarkUp(): ?float
{
return $this->min_mark_up;
}
public function setMinMarkUp(float $min_mark_up): self
{
$this->min_mark_up = $min_mark_up;
return $this;
}
public function getPackingType(): ?string
{
return $this->packing_type;
}
public function setPackingType(?string $packing_type): self
{
$this->packing_type = $packing_type;
return $this;
}
public function getPackingTypeCount(): ?float
{
return $this->packing_type_count;
}
public function setPackingTypeCount(?float $packing_type_count): self
{
$this->packing_type_count = $packing_type_count;
return $this;
}
public function getDiscounts(): ?int
{
return $this->discounts;
}
public function setDiscounts(?int $discounts): self
{
$this->discounts = $discounts;
return $this;
}
public function getTop(): ?int
{
return $this->top;
}
public function setTop(int $top): self
{
$this->top = $top;
return $this;
}
public function getCountOrder(): ?int
{
return $this->count_order;
}
public function setCountOrder(?int $count_order): self
{
$this->count_order = $count_order;
return $this;
}
public function getProductToOrder(): ?int
{
return $this->productToOrder;
}
public function setProductToOrder(?int $productToOrder): self
{
$this->productToOrder = $productToOrder;
return $this;
}
public function getMeasurementUnit(): ?MeasurmentUnit
{
return $this->measurement_unit;
}
public function setMeasurementUnit(?MeasurmentUnit $measurement_unit_id): self
{
$this->measurement_unit = $measurement_unit_id;
return $this;
}
/**
* @return Collection<int, ProductInfo>
*/
public function getProductInfos(): Collection
{
return $this->productInfos;
}
public function addProductInfo(ProductInfo $productInfo): self
{
if (!$this->productInfos->contains($productInfo)) {
$this->productInfos->add($productInfo);
$productInfo->setProduct($this);
}
return $this;
}
public function removeProductInfo(ProductInfo $productInfo): self
{
if ($this->productInfos->removeElement($productInfo)) {
// set the owning side to null (unless already changed)
if ($productInfo->getProduct() === $this) {
$productInfo->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, MediaObject>
*/
public function getMedia(): Collection
{
return $this->media;
}
public function addMedium(MediaObject $medium): self
{
if (!$this->media->contains($medium)) {
$this->media->add($medium);
$medium->setProduct($this);
}
return $this;
}
public function removeMedium(MediaObject $medium): self
{
if ($this->media->removeElement($medium)) {
// set the owning side to null (unless already changed)
if ($medium->getProduct() === $this) {
$medium->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, IncomingInvoiceProduct>
*/
public function getIncomingInvoiceProducts(): Collection
{
return $this->incomingInvoiceProducts;
}
public function addIncomingInvoiceProduct(IncomingInvoiceProduct $incomingInvoiceProduct): self
{
if (!$this->incomingInvoiceProducts->contains($incomingInvoiceProduct)) {
$this->incomingInvoiceProducts->add($incomingInvoiceProduct);
$incomingInvoiceProduct->setProduct($this);
}
return $this;
}
public function removeIncomingInvoiceProduct(IncomingInvoiceProduct $incomingInvoiceProduct): self
{
if ($this->incomingInvoiceProducts->removeElement($incomingInvoiceProduct)) {
// set the owning side to null (unless already changed)
if ($incomingInvoiceProduct->getProduct() === $this) {
$incomingInvoiceProduct->setProduct(null);
}
}
return $this;
}
#[ORM\PrePersist]
public function setCreatedAtValue(): void
{
$this->date_entered = new \DateTime();
// file_put_contents('/var/www/symfony_docker/public/errorrrrrr.log', $this->getCurrentUserId() . "\n", FILE_APPEND);
$this->created_by = $this->getCurrentUserId();
}
// #[ORM\PrePersist]
#[ORM\PreUpdate]
public function setUpdatedAtValue(): void
{
// file_put_contents('/var/www/symfony_docker/public/errorrrrrr.log', "222222\n", FILE_APPEND);
$this->date_modified = new \DateTime();
$this->modified_user = $this->getCurrentUserId();
}
public function getCurrentUserId(): ?User
{
// file_put_contents('/var/www/symfony_docker/public/errorrrrrr.log', print_r($this->security, true)."\n", FILE_APPEND);
if (!$this->security) {
return null;
}
$token = $this->security->getToken();
if (!$token) {
return null;
}
$user = $token->getUser();
if (!$user instanceof User) {
return null;
}
return $user;
}
public function __sleep()
{
return [
'modified_user',
// 'created_by',
// 'date_entered',
'date_modified'
];
}
public function __wakeup(): void
{
$this->security = null;
}
public function getArticle(): ?string
{
return $this->article;
}
public function setArticle(?string $article): self
{
$this->article = $article;
return $this;
}
public function getNds(): ?float
{
return $this->nds;
}
public function setNds(?float $nds): self
{
$this->nds = $nds;
return $this;
}
public function isService(): ?bool
{
return $this->service;
}
public function setService(?bool $service): self
{
$this->service = $service;
return $this;
}
public function isTransportService(): ?bool
{
return $this->transport_service;
}
public function setTransportService(?bool $transport_service): self
{
$this->transport_service = $transport_service;
return $this;
}
public function isExise(): ?bool
{
return $this->exise;
}
public function setExise(bool $exise): self
{
$this->exise = $exise;
return $this;
}
public function isExpirationDate(): ?bool
{
return $this->expiration_date;
}
public function setExpirationDate(?bool $expiration_date): self
{
$this->expiration_date = $expiration_date;
return $this;
}
public function getUnitVolume(): ?float
{
return $this->unit_volume;
}
public function setUnitVolume(?float $unit_volume): self
{
$this->unit_volume = $unit_volume;
return $this;
}
public function getNetWeight(): ?float
{
return $this->net_weight;
}
public function setNetWeight(?float $net_weight): self
{
$this->net_weight = $net_weight;
return $this;
}
public function getGrossWeight(): ?float
{
return $this->gross_weight;
}
public function setGrossWeight(?float $gross_weight): self
{
$this->gross_weight = $gross_weight;
return $this;
}
public function isGoByWeight(): ?bool
{
return $this->go_by_weight;
}
public function setGoByWeight(?bool $go_by_weight): self
{
$this->go_by_weight = $go_by_weight;
return $this;
}
public function getPackaging(): ?float
{
return $this->packaging;
}
public function setPackaging(?float $packaging): self
{
$this->packaging = $packaging;
return $this;
}
public function getSiteProduct(): ?SiteProducts
{
return $this->site_product;
}
public function setSiteProduct(?SiteProducts $site_product): self
{
$this->site_product = $site_product;
return $this;
}
/**
* @return Collection<int, Category>
*/
public function getCategory(): Collection
{
return $this->category;
}
public function addCategory(Category $category): self
{
if (!$this->category->contains($category)) {
$this->category->add($category);
}
return $this;
}
public function removeCategory(Category $category): self
{
$this->category->removeElement($category);
return $this;
}
/**
* @return Collection<int, MediaObject>
*/
public function getMediaObjects(): Collection
{
return $this->mediaObjects;
}
public function addMediaObject(MediaObject $mediaObject): self
{
if (!$this->mediaObjects->contains($mediaObject)) {
$this->mediaObjects->add($mediaObject);
$mediaObject->setProduct($this);
}
return $this;
}
public function removeMediaObject(MediaObject $mediaObject): self
{
if ($this->mediaObjects->removeElement($mediaObject)) {
// set the owning side to null (unless already changed)
if ($mediaObject->getProduct() === $this) {
$mediaObject->setProduct(null);
}
}
return $this;
}
public function getOldCode(): ?string
{
return $this->oldCode;
}
public function setOldCode(string $oldCode): self
{
$this->oldCode = $oldCode;
return $this;
}
/**
* @return Collection<int, UserLikeList>
*/
public function getUserLikeLists(): Collection
{
return $this->userLikeLists;
}
public function addUserLikeList(UserLikeList $userLikeList): self
{
if (!$this->userLikeLists->contains($userLikeList)) {
$this->userLikeLists->add($userLikeList);
$userLikeList->setз�product($this);
}
return $this;
}
public function removeUserLikeList(UserLikeList $userLikeList): self
{
if ($this->userLikeLists->removeElement($userLikeList)) {
// set the owning side to null (unless already changed)
if ($userLikeList->getз�product() === $this) {
$userLikeList->setз�product(null);
}
}
return $this;
}
/**
* @return Collection<int, AttributeItems>
*/
public function getAttributeItems(): Collection
{
return $this->attributeItems;
}
public function addAttributeItem(AttributeItems $attributeItem): self
{
if (!$this->attributeItems->contains($attributeItem)) {
$this->attributeItems->add($attributeItem);
$attributeItem->addProduct($this);
}
return $this;
}
public function removeAttributeItem(AttributeItems $attributeItem): self
{
if ($this->attributeItems->removeElement($attributeItem)) {
$attributeItem->removeProduct($this);
}
return $this;
}
public function isShow(): ?bool
{
return $this->show;
}
public function setShow(?bool $show): self
{
$this->show = $show;
return $this;
}
public function getStorage(): ?Storage
{
return $this->storage;
}
public function setStorage(?Storage $storage): self
{
$this->storage = $storage;
return $this;
}
public function getStorageElement(): ?StorageElement
{
return $this->storageElement;
}
public function setStorageElement(?StorageElement $storageElement): self
{
$this->storageElement = $storageElement;
return $this;
}
/**
* @return Collection<int, Prices>
*/
public function getPrices(): Collection
{
return $this->prices;
}
public function addPrice(Prices $price): static
{
if (!$this->prices->contains($price)) {
$this->prices->add($price);
$price->setAgreement($this);
}
return $this;
}
public function removePrice(Prices $price): static
{
if ($this->prices->removeElement($price)) {
// set the owning side to null (unless already changed)
if ($price->getAgreement() === $this) {
$price->setAgreement(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductBalanceInStorage>
*/
public function getProductBalanceInStorages(): Collection
{
return $this->productBalanceInStorages;
}
public function addProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
{
if (!$this->productBalanceInStorages->contains($productBalanceInStorage)) {
$this->productBalanceInStorages->add($productBalanceInStorage);
$productBalanceInStorage->setProduct($this);
}
return $this;
}
public function removeProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
{
if ($this->productBalanceInStorages->removeElement($productBalanceInStorage)) {
// set the owning side to null (unless already changed)
if ($productBalanceInStorage->getProduct() === $this) {
$productBalanceInStorage->setProduct(null);
}
}
return $this;
}
public function getBalance(): ?float
{
return $this->balance;
}
public function setBalance(?float $balance): self
{
$this->balance = $balance;
return $this;
}
/**
* @return Collection<int, OrderProduct>
*/
public function getOrderProducts(): Collection
{
return $this->orderProducts;
}
public function addOrderProduct(OrderProduct $orderProduct): self
{
if (!$this->orderProducts->contains($orderProduct)) {
$this->orderProducts->add($orderProduct);
$orderProduct->setOrder($this);
}
return $this;
}
public function removeOrderProduct(OrderProduct $orderProduct): self
{
if ($this->orderProducts->removeElement($orderProduct)) {
// set the owning side to null (unless already changed)
if ($orderProduct->getOrder() === $this) {
$orderProduct->setOrder(null);
}
}
return $this;
}
}