src/Entity/Photo.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PhotoRepository;
  4. use phpDocumentor\Reflection\Types\Integer;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass:PhotoRepository ::class)]
  7. class Photo
  8. {
  9.     //Déclarations des variables
  10.     #[ORM\Id]
  11.     #[ORM\Column(name'id_photo',type'integer'nullablefalse)]
  12.     #[ORM\GeneratedValue(strategy:'IDENTITY')]
  13.     private ?int $id;
  14.     #[ORM\Column(length255nullablefalse)]
  15.     private ?string $chemin null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $name null;
  18.     //Nullable est par défaut à false, donc on le précise que quand il est true
  19.     //Association
  20.     //On ajoute la relation ManyToOne où Photo est le propriétaire (=Many), (=inversedBy)
  21.     #[ORM\ManyToOne(targetEntityModel::class, inversedBy'photos')]
  22.     #[ORM\JoinColumn(referencedColumnName'id_model'nullabletrue)]
  23.     private ?Model $model null;
  24.     //Getters et Setters
  25.     /**
  26.      * @return int|null
  27.      */
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     /**
  33.      * @param int|null $id
  34.      */
  35.     public function setId(?int $id): void
  36.     {
  37.         $this->id $id;
  38.     }
  39.     /**
  40.      * @return Model|null
  41.      */
  42.     public function getModel(): ?Model
  43.     {
  44.         return $this->model;
  45.     }
  46.     /**
  47.      * @param Model|null $model
  48.      */
  49.     public function setModel(?Model $model): void
  50.     {
  51.         $this->model $model;
  52.     }
  53.     /**
  54.      * @return string|null
  55.      */
  56.     public function getChemin(): ?string
  57.     {
  58.         return $this->chemin;
  59.     }
  60.     /**
  61.      * @param string|null $chemin
  62.      */
  63.     public function setChemin(?string $chemin): void
  64.     {
  65.         $this->chemin $chemin;
  66.     }
  67.     /**
  68.      * @return string|null
  69.      */
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     /**
  75.      * @param string|null $name
  76.      */
  77.     public function setName(?string $name): void
  78.     {
  79.         $this->name $name;
  80.     }
  81. }