Skip to content
Snippets Groups Projects
Commit 1f1abc60 authored by Lucas's avatar Lucas
Browse files

relations

parent 49bb8de8
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
namespace App\Entity;
use App\Repository\FrequenceTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
......@@ -23,6 +25,14 @@ class FrequenceType
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\OneToMany(mappedBy: 'frequence_type_id', targetEntity: Panier::class)]
private Collection $paniers;
public function __construct()
{
$this->paniers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
......@@ -63,4 +73,34 @@ class FrequenceType
return $this;
}
/**
* @return Collection<int, Panier>
*/
public function getPaniers(): Collection
{
return $this->paniers;
}
public function addPanier(Panier $panier): static
{
if (!$this->paniers->contains($panier)) {
$this->paniers->add($panier);
$panier->setFrequenceTypeId($this);
}
return $this;
}
public function removePanier(Panier $panier): static
{
if ($this->paniers->removeElement($panier)) {
// set the owning side to null (unless already changed)
if ($panier->getFrequenceTypeId() === $this) {
$panier->setFrequenceTypeId(null);
}
}
return $this;
}
}
......@@ -23,6 +23,14 @@ class Panier
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(inversedBy: 'paniers')]
#[ORM\JoinColumn(nullable: false)]
private ?Unite $unite_id = null;
#[ORM\ManyToOne(inversedBy: 'paniers')]
#[ORM\JoinColumn(nullable: false)]
private ?FrequenceType $frequence_type_id = null;
public function getId(): ?int
{
return $this->id;
......@@ -63,4 +71,28 @@ class Panier
return $this;
}
public function getUniteId(): ?Unite
{
return $this->unite_id;
}
public function setUniteId(?Unite $unite_id): static
{
$this->unite_id = $unite_id;
return $this;
}
public function getFrequenceTypeId(): ?FrequenceType
{
return $this->frequence_type_id;
}
public function setFrequenceTypeId(?FrequenceType $frequence_type_id): static
{
$this->frequence_type_id = $frequence_type_id;
return $this;
}
}
......@@ -3,6 +3,8 @@
namespace App\Entity;
use App\Repository\UniteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: UniteRepository::class)]
......@@ -19,6 +21,14 @@ class Unite
#[ORM\Column]
private ?int $nbDecimale = null;
#[ORM\OneToMany(mappedBy: 'unite_id', targetEntity: Panier::class)]
private Collection $paniers;
public function __construct()
{
$this->paniers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
......@@ -54,4 +64,34 @@ class Unite
return $this;
}
/**
* @return Collection<int, Panier>
*/
public function getPaniers(): Collection
{
return $this->paniers;
}
public function addPanier(Panier $panier): static
{
if (!$this->paniers->contains($panier)) {
$this->paniers->add($panier);
$panier->setUniteId($this);
}
return $this;
}
public function removePanier(Panier $panier): static
{
if ($this->paniers->removeElement($panier)) {
// set the owning side to null (unless already changed)
if ($panier->getUniteId() === $this) {
$panier->setUniteId(null);
}
}
return $this;
}
}
......@@ -12,6 +12,4 @@ WORKDIR /var/www/symfony_docker
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
RUN composer install
\ No newline at end of file
RUN mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment