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
|
@ -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