src/Entity/Magasin.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MagasinRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassMagasinRepository::class)]
  8. class Magasin
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length150)]
  15.     private ?string $nom null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $logo_path null;
  18.     #[ORM\Column(nullabletrue)]
  19.     private ?bool $active null;
  20.    
  21.     #[ORM\OneToMany(mappedBy'magasin'targetEntityMagasinUser::class)]
  22.     private Collection $magasinsUser;
  23.     #[ORM\OneToMany(mappedBy'magasin'targetEntityProduit::class)]
  24.     private Collection $produits;
  25.     
  26.     public function __construct()
  27.     {
  28.         $this->user_id = new ArrayCollection();
  29.         $this->users = new ArrayCollection();
  30.         $this->magasinsUser = new ArrayCollection();
  31.         $this->produits = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getNom(): ?string
  38.     {
  39.         return $this->nom;
  40.     }
  41.     public function setNom(string $nom): static
  42.     {
  43.         $this->nom $nom;
  44.         return $this;
  45.     }
  46.     public function getLogoPath(): ?string
  47.     {
  48.         return $this->logo_path;
  49.     }
  50.     public function setLogoPath(?string $logo_path): static
  51.     {
  52.         $this->logo_path $logo_path;
  53.         return $this;
  54.     }
  55.     public function isActive(): ?bool
  56.     {
  57.         return $this->active;
  58.     }
  59.     public function setActive(?bool $active): static
  60.     {
  61.         $this->active $active;
  62.         return $this;
  63.     }
  64.     
  65.     public function __toString(): string
  66. {
  67.     return $this->nom// ou toute autre propriété lisible (ville, code, etc.)
  68. }
  69.     /**
  70.      * @return Collection<int, MagasinUser>
  71.      */
  72.     public function getMagasinsUser(): Collection
  73.     {
  74.         return $this->magasinsUser;
  75.     }
  76.     public function addMagasinsUser(MagasinUser $magasinsUser): static
  77.     {
  78.         if (!$this->magasinsUser->contains($magasinsUser)) {
  79.             $this->magasinsUser->add($magasinsUser);
  80.             $magasinsUser->setMagasin($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeMagasinsUser(MagasinUser $magasinsUser): static
  85.     {
  86.         if ($this->magasinsUser->removeElement($magasinsUser)) {
  87.             // set the owning side to null (unless already changed)
  88.             if ($magasinsUser->getMagasin() === $this) {
  89.                 $magasinsUser->setMagasin(null);
  90.             }
  91.         }
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return Collection<int, Produit>
  96.      */
  97.     public function getProduits(): Collection
  98.     {
  99.         return $this->produits;
  100.     }
  101.     public function addProduit(Produit $produit): static
  102.     {
  103.         if (!$this->produits->contains($produit)) {
  104.             $this->produits->add($produit);
  105.             $produit->setMagasin($this);
  106.         }
  107.         return $this;
  108.     }
  109.     public function removeProduit(Produit $produit): static
  110.     {
  111.         if ($this->produits->removeElement($produit)) {
  112.             // set the owning side to null (unless already changed)
  113.             if ($produit->getMagasin() === $this) {
  114.                 $produit->setMagasin(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }
  119. }