up schema with relations between objects

This commit is contained in:
Tykayn 2025-02-14 11:08:34 +01:00 committed by tykayn
parent 1c700917b3
commit 17e7fce7f8
8 changed files with 433 additions and 11 deletions

View file

@ -19,9 +19,6 @@ class Selling
#[ORM\Column(length: 255, nullable: true)]
private ?string $note = null;
#[ORM\Column(type: Types::OBJECT)]
private ?object $products = null;
#[ORM\Column]
private ?float $sum = null;
@ -34,9 +31,16 @@ class Selling
#[ORM\ManyToMany(targetEntity: GroupOfProducts::class, mappedBy: 'sellings')]
private Collection $groupOfProducts;
/**
* @var Collection<int, Product>
*/
#[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'sellings')]
private Collection $products;
public function __construct()
{
$this->groupOfProducts = new ArrayCollection();
$this->products = new ArrayCollection();
}
public function getId(): ?int
@ -118,4 +122,20 @@ class Selling
return $this;
}
public function addProduct(Product $product): static
{
if (!$this->products->contains($product)) {
$this->products->add($product);
}
return $this;
}
public function removeProduct(Product $product): static
{
$this->products->removeElement($product);
return $this;
}
}