symfony No identifier/primary key specified for Entity "App\Entity\Etablissement"

19 views Asked by At

I have a problem with the Entity Etablissement, i m sure that the Every Entity must have an identifier/primary key.But i guess i wrong, there is the entity Etablissement causing the problem if someone could help : Maybe i should add auto_increment somewhere but i don t know if it s a good solution

<?php

namespace App\Entity;

use...


#[ORM\Entity(repositoryClass: EtablissementRepository::class)]
class Etablissement
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="Le nom de l'établissement est requis.")
     */

    private $appellationOfficielle;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="La dénomination principale est requise.")
     */
    private $denominationPrincipale;



    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\Choice(choices={"public", "privé"}, message="Le secteur doit être 'public' ou 'privé'.")
     */
    private $secteur;

    /**
     * @ORM\Column(type="float")
     * @Assert\NotBlank(message="La longitude est requise.")
     * @Assert\Range(
     *      min = -180,
     *      max = 180,
     *      notInRangeMessage = "La longitude doit être entre {{ min }} et {{ max }} degrés."
     * )
     */
    private $longitude;

    /**
     * @ORM\Column(type="float")
     * @Assert\NotBlank(message="La latitude est requise.")
     * @Assert\Range(
     *      min = -90,
     *      max = 90,
     *      notInRangeMessage = "La latitude doit être entre {{ min }} et {{ max }} degrés."
     * )
     */
    private $latitude;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="L'adresse est requise.")
     */
    private $adresse;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="Le département est requis.")
     */
    private $departement;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="La commune est requise.")
     */
    private $commune;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="La région est requise.")
     */
    private $region;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank(message="L'académie est requise.")
     */
    private $academie;

    /**
     * @ORM\Column(type="datetime")
     * @Assert\NotBlank(message="La date d'ouverture est requise.")
     */
    private $dateOuverture;

    /**
     * @ORM\OneToMany(targetEntity=Commentaire::class, mappedBy="etablissement")
     */
    private $commentaires;

    public function __construct()
    {
        $this->commentaires = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getAppellationOfficielle(): ?string
    {
        return $this->appellationOfficielle;
    }

    public function setAppellationOfficielle(string $appellationOfficielle): self
    {
        $this->appellationOfficielle = $appellationOfficielle;

        return $this;
    }

    public function getDenominationPrincipale(): ?string
    {
        return $this->denominationPrincipale;
    }

    public function setDenominationPrincipale(string $denominationPrincipale): self
    {
        $this->denominationPrincipale = $denominationPrincipale;

        return $this;
    }

    public function getSecteur(): ?string
    {
        return $this->secteur;
    }

    public function setSecteur(string $secteur): self
    {
        $this->secteur = $secteur;

        return $this;
    }


    public function getLongitude(): ?float
    {
        return $this->longitude;
    }

    public function setLongitude(float $longitude): self
    {
        $this->longitude = $longitude;

        return $this;
    }

    public function getLatitude(): ?float
    {
        return $this->latitude;
    }

    public function setLatitude(float $latitude): self
    {
        $this->latitude = $latitude;

        return $this;
    }

    public function getAdresse(): ?string
    {
        return $this->adresse;
    }

    public function setAdresse(string $adresse): self
    {
        $this->adresse = $adresse;

        return $this;
    }

    public function getDepartement(): ?string
    {
        return $this->departement;
    }

    public function setDepartement(string $departement): self
    {
        $this->departement = $departement;

        return $this;
    }

    public function getCommune(): ?string
    {
        return $this->commune;
    }

    public function setCommune(string $commune): self
    {
        $this->commune = $commune;

        return $this;
    }

    public function getRegion(): ?string
    {
        return $this->region;
    }

    public function setRegion(string $region): self
    {
        $this->region = $region;

        return $this;
    }

    public function getAcademie(): ?string
    {
        return $this->academie;
    }

    public function setAcademie(string $academie): self
    {
        $this->academie = $academie;

        return $this;
    }

    public function getDateOuverture(): ?\DateTimeInterface
    {
        return $this->dateOuverture;
    }

    public function setDateOuverture(\DateTimeInterface $dateOuverture): self
    {
        $this->dateOuverture = $dateOuverture;

        return $this;
    }

    public function addCommentaire(Commentaire $commentaire): self
    {
        if (!$this->commentaires->contains($commentaire)) {
            $this->commentaires[] = $commentaire;
            $commentaire->setEtablissement($this);
        }

        return $this;
    }

    public function removeCommentaire(Commentaire $commentaire): self
    {
        if ($this->commentaires->removeElement($commentaire)) {
            if ($commentaire->getEtablissement() === $this) {
                $commentaire->setEtablissement(null);
            }
        }

        return $this;
    }

    public function getCommentaires(): Collection
    {
        return $this->commentaires;
    }
}

i verified the keys but with no solution

0

There are 0 answers