src/Entity/Auteur.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AuteurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassAuteurRepository::class)]
  9. class Auteur
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255nullabletrue)]
  16.     private ?string $nom null;
  17.     #[ORM\ManyToMany(targetEntityPublication::class, mappedBy'auteur')]
  18.     private Collection $publications;
  19.     #[ORM\ManyToOne(inversedBy'auteurs')]
  20.     private ?Chercheur $chercheur null;
  21.     public function __construct()
  22.     {
  23.         $this->publications = new ArrayCollection();
  24.     }
  25.    
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getNom(): ?string
  31.     {
  32.         return $this->nom;
  33.     }
  34.     public function setNom(?string $nom): self
  35.     {
  36.         $this->nom $nom;
  37.         return $this;
  38.     }
  39.    
  40.     public function getCreatedAt(): ?\DateTimeInterface
  41.     {
  42.         return $this->createdAt;
  43.     }
  44.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  45.     {
  46.         $this->createdAt $createdAt;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Publication>
  51.      */
  52.     public function getPublications(): Collection
  53.     {
  54.         return $this->publications;
  55.     }
  56.     public function addPublication(Publication $publication): self
  57.     {
  58.         if (!$this->publications->contains($publication)) {
  59.             $this->publications->add($publication);
  60.             $publication->addAuteur($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removePublication(Publication $publication): self
  65.     {
  66.         if ($this->publications->removeElement($publication)) {
  67.             $publication->removeAuteur($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function getChercheur(): ?Chercheur
  72.     {
  73.         return $this->chercheur;
  74.     }
  75.     public function setChercheur(?Chercheur $chercheur): self
  76.     {
  77.         $this->chercheur $chercheur;
  78.         return $this;
  79.     }
  80.    
  81. }