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\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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue