src/Entity/Vendeur.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\VendeurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassVendeurRepository::class)]
  8. #[ORM\UniqueConstraint(
  9.     name'index1',
  10.     columns: ['id''code_vendeur']
  11. )]
  12. class Vendeur
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     //#[ORM\Column(unique:true)]
  17.     #[ORM\Column()]
  18.     private ?int $id null;
  19.     
  20.     #[ORM\Column(nullable:false)]
  21.     private ?int $code_vendeur null;
  22.     #[ORM\Column(length250nullabletrue)]
  23.     private ?string $nom_vendeur null;
  24.     #[ORM\OneToMany(mappedBy'vendeur'targetEntityUser::class)]
  25.     private Collection $users;
  26.     #[ORM\OneToMany(mappedBy'vendeur'targetEntityStatistiques::class)]
  27.     private Collection $statistiques;
  28.     public function __construct()
  29.     {
  30.         $this->users = new ArrayCollection();
  31.         $this->statistiques = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function setId(int $id): self
  38.     {
  39.         $this->id $id;
  40.         return $this;
  41.     }
  42.     public function getCodeVendeur(): ?int
  43.     {
  44.         return $this->code_vendeur;
  45.     }
  46.     public function setCodeVendeur(int $code_vendeur): self
  47.     {
  48.         $this->code_vendeur $code_vendeur;
  49.         return $this;
  50.     }
  51.     public function getNomVendeur(): ?string
  52.     {
  53.         return $this->nom_vendeur;
  54.     }
  55.     public function setNomVendeur(?string $nom_vendeur): self
  56.     {
  57.         $this->nom_vendeur $nom_vendeur;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, User>
  62.      */
  63.     public function getUsers(): Collection
  64.     {
  65.         return $this->users;
  66.     }
  67.     public function addUser(User $user): self
  68.     {
  69.         if (!$this->users->contains($user)) {
  70.             $this->users->add($user);
  71.             $user->setVendeur($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeUser(User $user): self
  76.     {
  77.         if ($this->users->removeElement($user)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($user->getVendeur() === $this) {
  80.                 $user->setVendeur(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Statistiques>
  87.      */
  88.     public function getStatistiques(): Collection
  89.     {
  90.         return $this->statistiques;
  91.     }
  92.     public function addStatistique(Statistiques $statistique): self
  93.     {
  94.         if (!$this->statistiques->contains($statistique)) {
  95.             $this->statistiques->add($statistique);
  96.             $statistique->setVendeur($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeStatistique(Statistiques $statistique): self
  101.     {
  102.         if ($this->statistiques->removeElement($statistique)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($statistique->getVendeur() === $this) {
  105.                 $statistique->setVendeur(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110. }