src/Entity/Marque.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\MarqueRepository")
  11.  * @Vich\Uploadable
  12.  */
  13. class Marque
  14. {
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=50)
  23.      */
  24.     private $nom;
  25.     /**
  26.      * @ORM\Column(type="string", length=50, nullable=true)
  27.      */
  28.     private $logo;
  29.     /**
  30.      * @Vich\UploadableField(mapping="marque_upload", fileNameProperty="logo")
  31.      * @var File
  32.      */
  33.     private $logoFile;
  34.     /**
  35.      * @ORM\Column(type="string", length=50, nullable=true)
  36.      */
  37.     private $siteOfficiel;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity="App\Entity\Voiture", mappedBy="marque", orphanRemoval=true)
  40.      */
  41.     private $voitures;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @Gedmo\Slug(fields={"nom"})
  46.      * @ORM\Column(type="string", unique=true)
  47.      */
  48.     private $slug;
  49.     public function __construct()
  50.     {
  51.         $this->voitures = new ArrayCollection();
  52.     }
  53.     public function getSlug():string
  54.     {
  55.         return $this->slug;
  56.     }
  57.     public function setSlug($slug): string
  58.     {
  59.         $this->slug $slug;
  60.         return $this;
  61.     }
  62.     /**
  63.      * @param File|null $imageFile
  64.      */
  65.     public function setImageFile(?File $imageFile null)
  66.     {
  67.         $this->imageFile $imageFile;
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getNom(): ?string
  74.     {
  75.         return $this->nom;
  76.     }
  77.     public function setNom(string $nom): self
  78.     {
  79.         $this->nom $nom;
  80.         return $this;
  81.     }
  82.     public function getLogo(): ?string
  83.     {
  84.         return $this->logo;
  85.     }
  86.     public function setLogo(?string $logo): self
  87.     {
  88.         $this->logo $logo;
  89.         return $this;
  90.     }
  91.     public function getLogoFile()
  92.     {
  93.         return $this->logoFile;
  94.     }
  95.     public function setLogoFile(File $logoFile null)
  96.     {
  97.         $this->logoFile $logoFile;
  98.         return $this;
  99.     }
  100.     public function getSiteOfficiel(): ?string
  101.     {
  102.         return $this->siteOfficiel;
  103.     }
  104.     public function setSiteOfficiel(?string $siteOfficiel): self
  105.     {
  106.         $this->siteOfficiel $siteOfficiel;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection|Voiture[]
  111.      */
  112.     public function getVoitures(): Collection
  113.     {
  114.         return $this->voitures;
  115.     }
  116.     public function addVoiture(Voiture $voiture): self
  117.     {
  118.         if (!$this->voitures->contains($voiture)) {
  119.             $this->voitures[] = $voiture;
  120.             $voiture->setMarque($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeVoiture(Voiture $voiture): self
  125.     {
  126.         if ($this->voitures->contains($voiture)) {
  127.             $this->voitures->removeElement($voiture);
  128.             // set the owning side to null (unless already changed)
  129.             if ($voiture->getMarque() === $this) {
  130.                 $voiture->setMarque(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135.     public function __toString()
  136.     {
  137.         return $this->nom;
  138.     }
  139. }