mirror of
https://forge.chapril.org/tykayn/caisse-bliss
synced 2025-06-20 01:44:42 +02:00
up schema with relations between objects
This commit is contained in:
parent
1c700917b3
commit
17e7fce7f8
8 changed files with 433 additions and 11 deletions
|
@ -16,6 +16,9 @@ class Category
|
|||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'categories')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -32,4 +35,16 @@ class Category
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ class Expense
|
|||
#[ORM\Column]
|
||||
private ?float $price = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'expenses')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -47,4 +50,16 @@ class Expense
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\FestivalRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
|
@ -23,6 +25,20 @@ class Festival
|
|||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $date_end = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, User>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'currentFestival')]
|
||||
private Collection $users;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'festivals')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->users = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -63,4 +79,46 @@ class Festival
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, User>
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public function addUser(User $user): static
|
||||
{
|
||||
if (!$this->users->contains($user)) {
|
||||
$this->users->add($user);
|
||||
$user->setCurrentFestival($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeUser(User $user): static
|
||||
{
|
||||
if ($this->users->removeElement($user)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($user->getCurrentFestival() === $this) {
|
||||
$user->setCurrentFestival(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ class GroupOfProducts
|
|||
#[ORM\ManyToMany(targetEntity: Selling::class, inversedBy: 'groupOfProducts')]
|
||||
private Collection $sellings;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'groupOfProducts')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->products = new ArrayCollection();
|
||||
|
@ -106,4 +109,16 @@ class GroupOfProducts
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,19 @@ class Product
|
|||
#[ORM\ManyToMany(targetEntity: GroupOfProducts::class, mappedBy: 'products')]
|
||||
private Collection $groupOfProducts;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Selling>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Selling::class, mappedBy: 'products')]
|
||||
private Collection $sellings;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'products')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->groupOfProducts = new ArrayCollection();
|
||||
$this->sellings = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
|
@ -102,4 +112,43 @@ class Product
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Selling>
|
||||
*/
|
||||
public function getSellings(): Collection
|
||||
{
|
||||
return $this->sellings;
|
||||
}
|
||||
|
||||
public function addSelling(Selling $selling): static
|
||||
{
|
||||
if (!$this->sellings->contains($selling)) {
|
||||
$this->sellings->add($selling);
|
||||
$selling->addProduct($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSelling(Selling $selling): static
|
||||
{
|
||||
if ($this->sellings->removeElement($selling)) {
|
||||
$selling->removeProduct($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
@ -34,17 +36,50 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||
#[ORM\Column]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\Column(type: Types::OBJECT)]
|
||||
private ?object $owner = null;
|
||||
|
||||
#[ORM\Column(type: Types::OBJECT, nullable: true)]
|
||||
private ?object $expenses = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $isVerified = false;
|
||||
|
||||
#[ORM\Column(type: Types::OBJECT, nullable: true)]
|
||||
private ?object $currentFestival = null;
|
||||
#[ORM\ManyToOne(inversedBy: 'users')]
|
||||
private ?Festival $currentFestival = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Expense>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Expense::class, mappedBy: 'user')]
|
||||
private Collection $expenses;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Product>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Product::class, mappedBy: 'user')]
|
||||
private Collection $products;
|
||||
|
||||
/**
|
||||
* @var Collection<int, GroupOfProducts>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: GroupOfProducts::class, mappedBy: 'user')]
|
||||
private Collection $groupOfProducts;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Festival>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Festival::class, mappedBy: 'user')]
|
||||
private Collection $festivals;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Category>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'user')]
|
||||
private Collection $categories;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->expenses = new ArrayCollection();
|
||||
$this->products = new ArrayCollection();
|
||||
$this->groupOfProducts = new ArrayCollection();
|
||||
$this->festivals = new ArrayCollection();
|
||||
$this->categories = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
|
@ -168,4 +203,146 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addExpense(Expense $expense): static
|
||||
{
|
||||
if (!$this->expenses->contains($expense)) {
|
||||
$this->expenses->add($expense);
|
||||
$expense->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeExpense(Expense $expense): static
|
||||
{
|
||||
if ($this->expenses->removeElement($expense)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($expense->getUser() === $this) {
|
||||
$expense->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Product>
|
||||
*/
|
||||
public function getProducts(): Collection
|
||||
{
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
public function addProduct(Product $product): static
|
||||
{
|
||||
if (!$this->products->contains($product)) {
|
||||
$this->products->add($product);
|
||||
$product->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeProduct(Product $product): static
|
||||
{
|
||||
if ($this->products->removeElement($product)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($product->getUser() === $this) {
|
||||
$product->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, GroupOfProducts>
|
||||
*/
|
||||
public function getGroupOfProducts(): Collection
|
||||
{
|
||||
return $this->groupOfProducts;
|
||||
}
|
||||
|
||||
public function addGroupOfProduct(GroupOfProducts $groupOfProduct): static
|
||||
{
|
||||
if (!$this->groupOfProducts->contains($groupOfProduct)) {
|
||||
$this->groupOfProducts->add($groupOfProduct);
|
||||
$groupOfProduct->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeGroupOfProduct(GroupOfProducts $groupOfProduct): static
|
||||
{
|
||||
if ($this->groupOfProducts->removeElement($groupOfProduct)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($groupOfProduct->getUser() === $this) {
|
||||
$groupOfProduct->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Festival>
|
||||
*/
|
||||
public function getFestivals(): Collection
|
||||
{
|
||||
return $this->festivals;
|
||||
}
|
||||
|
||||
public function addFestival(Festival $festival): static
|
||||
{
|
||||
if (!$this->festivals->contains($festival)) {
|
||||
$this->festivals->add($festival);
|
||||
$festival->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFestival(Festival $festival): static
|
||||
{
|
||||
if ($this->festivals->removeElement($festival)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($festival->getUser() === $this) {
|
||||
$festival->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Category>
|
||||
*/
|
||||
public function getCategories(): Collection
|
||||
{
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
public function addCategory(Category $category): static
|
||||
{
|
||||
if (!$this->categories->contains($category)) {
|
||||
$this->categories->add($category);
|
||||
$category->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeCategory(Category $category): static
|
||||
{
|
||||
if ($this->categories->removeElement($category)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($category->getUser() === $this) {
|
||||
$category->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue