src/Entity/Constructeur.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ConstructeurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassConstructeurRepository::class)]
  8. class Constructeur
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length20)]
  15.     private ?string $nom null;
  16.     #[ORM\OneToMany(mappedBy'constructeur'targetEntityCamion::class)]
  17.     private Collection $camions;
  18.     #[ORM\Column(length50)]
  19.     private ?string $telephone null;
  20.     public function __construct()
  21.     {
  22.         $this->camions = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getNom(): ?string
  29.     {
  30.         return $this->nom;
  31.     }
  32.     public function setNom(string $nom): static
  33.     {
  34.         $this->nom $nom;
  35.         return $this;
  36.     }
  37.     /**
  38.      * @return Collection<int, Camion>
  39.      */
  40.     public function getCamions(): Collection
  41.     {
  42.         return $this->camions;
  43.     }
  44.     public function addCamions(Camion $camion): static
  45.     {
  46.         if (!$this->camions->contains($camion)) {
  47.             $this->camions->add($camion);
  48.             $camion->setConstructeur($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeCamions(Camion $camion): static
  53.     {
  54.         if ($this->camions->removeElement($camion)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($camion->getConstructeur() === $this) {
  57.                 $camion->setConstructeur(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62.     public function __toString()
  63.     {
  64.         return $this->getNom();
  65.     }
  66.     public function getTelephone(): ?string
  67.     {
  68.         return $this->telephone;
  69.     }
  70.     public function setTelephone(string $telephone): static
  71.     {
  72.         $this->telephone $telephone;
  73.         return $this;
  74.     }
  75. }